As long as you are training your dog accidents are bound to happen. You should never impose punishments as this will only lead to fear. If you see him doing his thing in the wrong place you need to get his attention immediately.