'I went to visit a dentist. At first I was scared, but then I realised the dentist was very nice' is the correct answer. Since we are talking about this dentist for the first time, we use 'a' before it. But we later talk about the same dentist again, so this time use 'the' before it.