Never punish your dog. Firstly it does not work, secondly, it can make behavior much worse through minimizing trust and increasing fear. If there is a behavior you do not like, use positive reinforcement gradually to encourage the desired behavior instead. Clicker training is also a useful tool to help minimize unwanted behavior. However, you need to be sure that your dog is healthy and happy first. To ensure this you may want to visit your vet or a behaviorist to ensure things are normal.