Many of us just responded here to another mother who didn't see her daughter about to tackle their sleeping dog, and the dog promptly bit the little girl in the face. The bottom line is that until you are able to make sure your son doesn't hurt the dog (like he is now doing), you need to keep them at a distance from each other.
When a dog bites because it is being hurt, everyone then wants to blame the dog. Not only is this not fair to the dog, but your son could truly be hurt when the dog has had enough. Children have been mauled and killed by dogs and I daresay many of them were abusing the dogs in some way.
Your son, at almost 2, is old enough to learn what you are trying to teach him (unless there is a developmental delay). It is a matter of you being consistent in your "punishment" of his misbehavior. If he kicks or hits the dog, he needs to be removed from where the dog is and not allowed near him--and not just for 5 or 10 minutes and then allowed to do it again. By not being consistent with whatever discipline you are using to deal with this, you are probably reinforcing this bad behavior. Please protect both your son and your dog and put a stop to this before it goes too far.