In the following sentence, is it correct to use came or went, in a situation when a person is talking to his/her friend?

"After I came/went to David's house, I noticed that there wasn't anybody home."

If you are in David's house, you'd use "came."

If you are not in David's house, you'd use "went."

To determine whether to use "came" or "went" in the sentence, you need to consider the perspective of the person speaking. If the speaker is currently at David's house, then they would use "came" since they are referring to their arrival at the current location. On the other hand, if the speaker is somewhere else, talking about their visit to David's house in the past, then they would use "went" since they are referring to leaving their original location and heading to David's house.

So, in order to choose between "came" and "went," you need to know the speaker's perspective relative to David's house at the time of speaking.

Example 1: If the speaker is currently at David's house and speaking to their friend who is also present, they would say, "After I came to David's house, I noticed that there wasn't anybody home."

Example 2: If the speaker is somewhere else and recalling their visit to David's house in the past while talking to their friend, they would say, "After I went to David's house, I noticed that there wasn't anybody home."

Therefore, the correct choice between "came" and "went" depends on the perspective of the speaker, relative to David's house, at the time of speaking.