Even though your dog in may stop whatever behavior you wanted it to cease after you hit him, this doesn't necessarily mean he understands what behavior you were referring to. Dogs don't always associate your punishment with what they have just done. More often than not, they're simply associating the corporal punishment it with you, and making the judgment that you, the owner, is an aggressive, violent person whom they should either fear, or fight.
This is generally why hitting your dog may only really lead to one of two things: making them more fearful of you, or making them more aggressive.
And beyond that, hitting your dog is not okay for the simple fact that it is animal abuse.
In fact, if you really think about it, hitting your dog as a form of communication doesn't really make any sense at all. You and your dog do not speak the same language, so why would you assume that by using physical punishment they would understand what you're trying to communicate? If you met someone from a foreign country who didn't speak your language, would your first response to them not being able to understand you or your culture be to punch him in the face? I think not. And that person probably wouldn't know WHY you punched them either.
In my experience, a much more effective way to ensure your dog does not repeat bad behavior is to simply enforce positive behavior.
For example, if your dog relieves himself inside the house, don't scream, yell or hit. He won't understand whether you're angry because he relieved himself on the floor, that specific part of the floor, or if you're just angry that he relieved himself at all.
A much more effective way to control your dog behavior would be for you to reward him when he does his business in the area you have designated for such behavior. When you praise him or give him treats when he relieves himself in the correct location, this reinforces in your dog's the behavior that you like, and that they know that if they repeat the action in the future they will probably be rewarded again. So the next time they feel like they have to go, instead of going in a place where they know they won't be rewarded positively, they will opt for the place where expect they will be rewarded with something in return. Over time, it simply becomes habit.
And if you're a skeptic who has doubts as to whether this actually works, at least consider this: I house broke my dog in under a month and a half when he was only 3-4 months old by using only positive reinforcement.