So you get frustrated with your dog and you hit him, and the you feel guilty about it? Yeah, that's not torturing animals. It isn't right, though; your dog doesn't deserve it.
I used to do things like hold my cat when she didn't want to be held, or grab her tail and hold on while she tried to get away, or pinch my little sister's ear, or any number of small cruelties... Most of those things I did when I was in my very early teens--11 to 13 or so. I don't know why I did them--"experimenting" with negative emotion might be an explanation, though it's not a very good one--but I eventually stopped (because I knew it was wrong), and haven't done anything near that cruel since. So I don't think it is some horrible problem; it is probably something you can stop on your own.
Try this:
Whenever you feel like you are about to do something like that, get away from your dog. Go across the room, to a different room, back inside... Whenever you think about hurting an animal, consciously stop yourself from thinking it.
What you are doing seems relatively mild... your dog seems pretty tolerant. But you don't want to hurt him, so don't. If you have to hit something, pick a non-living target.