Calling your dog and punishing him is not a good practice, since he has just followed your command. This can make him have second thoughts of approaching you whenever you call him.
Thus, only punish your dog, whenever he does something bad. Aside from that, punish him on the instance of showing his undesirable behavior, so that he would know what it is all about.
Do not punish desirable behavior
Punishing desirable behavior can be confusing to your pet, which is why it should not be practiced. Keep in mind that you may be doing it, even without your intension.
For example, if you want your puppy to eliminate outside the house, then you should be with him until he does it. Leaving him alone outside may make him feel that he is being punished, especially if he wants to be with you.