First off - the fact that he is doing this with such frequency means that he is not housebroken. A truly housebroken dog does not lift his leg in the house. Period. End of discussion. I have a 3 year old intact male that wouldn't lift his leg in my house if his life depended on it! And I trained him without ever raising a hand to him.
Stop hitting your dog! Dogs don't think like people. He has no idea why you are hitting him but he is fast learning that you are a bully and not to be trusted.
Back to basics. Out on a schedule, leash him to you when you can keep an eye on him, crate him when you can't. Crate him at night and when you are not home. Keep him off the furniture.