No matter how house trained your dog or puppy, they are bound to have an accident in your home at some point. Whether it be from holding it in for too long, eating something that sit well, or even from excitation (A dog that's holding in its urine has a very difficult time holding it in if it is excitedly running around your home).
But there is a correct way and an incorrect way to deal with an accident.
Popular opinion teachers you that the best way to teach your dog not to have an accident in your home is to hold its nose in it until it realizes that it should not have gone there. But in truth, this is the absolute worst thing you can do to a dog. Dogs are not people. No matter how smart they may be, they do not understand why you are holding their head in their own waste. But, because they are not stupid creatures, they are aware that you are doing it for a reason.
By holding a dog's head in its waste, you are teaching it that it did something wrong, but not what it did wrong or how to fix it. Dogs that are punished in this method tend to become afraid of their owners and sometimes afraid of even going to the bathroom at all, because they associate the smell of their own waste with punishment. Some dogs even beginning hiding from their owners before they go to the bathroom in order to avoid getting yelled at. If this happens to you, you may find some unfortunates "presents" in closets or behind chairs.
Similarly, if you notice that your dog has had an accident, but you were not witnessing it happen, it is already too late to punish your dog. Dogs only understand what has happened to them recently. Once the business has been completed, yelling at your dog will only make the dog feel it has been punished for whatever it just did (often times that includes running up to its owner, which can cause the dog to be scared to come to you) .
For dogs, rewards are always better then punishment, and the best way to train your dog out of leaving accidents in your house is to continue to reward it for going outside. And if this is a onetime affair, because your dog is generally well house trained, the best thing to do is ignore it completely and clean up the spot as well as you can in order to get out any trace of the smell.
However, if you insist on punishing your dog, you must do so while it is in the act of the accident. Punishing the dog while it is urinating on your wall or carpet is the only way your dog will realize that the punishment is for the accident, not for anything else. And never, ever call your dog over for the punishment. If you see your dog about to go on your carpet, run over to your dog and stop it there. Calling your dog over and punishment it will, again, cause the dog to associate the punishment being due to coming over to you, and not for the accident it just made.
If your dog is properly house trained, these accidents should be few and far between, and are best left ignored. However, if you notice a pattern and insist on punishing your dog or puppy, avoiding those common practices like holding its head in its waste can help make sure your dog does not feel it is being punished unfairly, and it will relearn to go outside soon enough.