Why does my dog pee when I pet him? (Submissive Peeing)
Submissive peeing is a submissive gesture that can happen when a dog is over-excited, anxious and/or fearful. You cannot punish your dog for submissive peeing because your dog is not doing it on purpose and cannot help it. If your dog is young, it can sometimes be outgrown.
How do I work on stopping it?
To help dogs overcome this behavior, along with taking some extra housebreaking precautions, you are going to have to work on getting their minds to calm down. Start teaching them canine-to-human respect, take them for daily walks where they are heeling on the lead and not pulling. They have to be following you, not you following them. Teach them to enter and exit all gate and doorways after humans and exercise them by walking them for long periods of time to help them relax and drain their energy. This should help them not pee from excitement. Recognize any dominancy behaviors if any are present and work at calmly, but firmly correcting them so the dog can feel secure. Dogs that do not see a clear pattern of leadership often worry about their pack.
When you get home from being gone, ignore your dog. Move slowly, and keep it calm. One tactic you can try is to walk sideways or backward. Do not praise it as this will create excitement. Do not get on the ground with it and do not lean over it. Do not bend down toward it, or look at it in the eyes and do not face it head-on. When you walk into the house and it runs to you, do not stop and reach down to pet it. Go to the bathroom or do something besides greeting it immediately until it calms down.
Advise guests to do the same. Inform your guests ahead of time to please completely ignore the dog.
A little later, let your dog come to you. It may take a while, but it can be done. You can gradually adjust your motions as you see its confidence-building and its mind calming.