Yes, you need to take him to the vet asap to rule out anything medical (most likely it is something medical, and there might be a trial and error period).

In the mean time, I'm sure the dog doesn't enjoy going potty in the house, and doesn't like getting in trouble for it. But as you said, he just might not be able to help it.
So go ahead and keep him crated when you can, and/or keep him on a leash, tethered to your belt loop. That way you can keep an eye on him, and catch him from peeing while your walking or sitting around the house.
In addition, take him out every hour, on the hour to help lessen the chance of accidents.