While it may be tempting to correct the bad behavior with a spank, you should never discipline your dog physically. Spanking is confusing to your dog, may cause your dog to become hand-shy or fearful of you, and most importantly, doesn't teach him the desired behavior.
Do Puppies remember if you hit them?
It appears that dogs may remember more than we realize, but they're still highly unlikely to remember if you hit them as long as you don't make a habit of it. A dog easily forgets one-off events, but they can remember intense sensations or ongoing actions through associative memory.
Should you ever punish a puppy?
The short answer is: no. It is not OK to punish your puppy. The most important thing during a puppy's first months of life is to teach him that you are his friend and protector and that you are reliable, predictable and fun. Your puppy most likely has no idea what you are punishing him for if you discipline him.