I do not know how old you guys are. It could be that he reached puberty and is becoming awkward with girls. He probaly has guy friends too, and maybe he doesn't want to be bullied.
But him not hugging you anymore could have several other reasons. It could be your personal hygiëne, or him having an awkward boner everytime he sees you and feels ashamed by it. I don't know. Remember, he IS a boy, and some guys just are weird about it. I wouldn't blame myself if I were you. You are still his best friend and as long as that doesn't change, he certainly cares a lot for you and keeps hanging out with you, and that is what matters the most.
But being best friends, also means that you can talk about everything. I would not ask something like: "Why do you not hug me anymore? Did I do something wrong? :c" but more something like: tries to hug him and he refuses "EY what's the matter? Do I smell or something? Hahaha." that makes him at ease with you and it won't turn this problem into a HUGE ONE. I'm sure it isn't, and then he will give you some answers perhaps.
Don't worry too much about it and talk to him. I'm sure you will laugh about it once you guys come clean with eachother.
Good luck! I hope this will help you out.
ANSWER THIS QUESTION