This behaviour can be for a couple of reasons. One reason is that your dog may be marking his territory. He is putting his scent on you so other dogs know that you belong to him. This marking can happen if you haven’t correctly asserted your dominance as your dog's ‘pack leader’.
A guilty looking Pug lying down on the kitchen floor
The second reason is that your dog may urinate on you when he is excited to see you. If this is the reason it will usually only happen when you have arrived home after work or a day out. Some dogs do this as a submissive gesture. They wee to let you know that they are of no threat to you.