The article "the" is used for a noun where you know the exact noun you are talking about.
A: "Did you buy a dog yesterday?" [Use 'a' because we don't know which dog B bought. It could be any dog.]
B: "Yes I bought a dog. It was a scottie" [Again, up to this point we still don't know which dog."]
A: "What is the dog's name?" [Because of the last sentence, we know which dog we are talking about - the dog that B bought - so, we use 'the']