How old is your dog, and how old are you? Your dog needs obedience training and careful handling in order to stop this from becoming out of control. Do you have access to obedience classes, and what breed is your dog?
is the dog afraid of u? if so then when it is trying to bite, grab the bottom side of his mouth where his tongue is. i know this sounds kind of cruel, but thats what a dog trainer told me to do with the same problem and it worked.