Humping is often from general over-excitement or possibly stress, it's very seldom sexual. So I'd guess he is just excited and then, like a young child who is distracted by what he is doing, he hasn't noticed his need to pee until its too late.
I'd make sure he has toileted before he can get to the bed. And there are various schools of thought on what to do about the humping. Either redirect him, by distracting him with something else or a walk or - let him hump the bed. If it doesn't do him or the bed any harm, it is an option.
There's more here -
Clients frequently ask me what to do when their dog is humping. First, look at the situation. Why is your dog humping? The whys becomes important, because it will determine how we will work with the behavior.
positively.com