A sudden surge in anxiety or stress can cause your dog to yelp in a painful tone. It could be sensed in the environment that he is reacting to. In addition to being frightened by a stranger in his territory, he may also suffer from behavioral issues such as separation anxiety.