Researchers timed hundreds of post-competition hugs by competitors at the 2008 Beijing Summer Olympics and found that the average hug lasts three seconds. Apparently, this isn't the only human action that follows the three-second rule — babies tend to babble in three-second bursts, and the average goodbye wave also lasts three seconds.
More facts about the "three-second rule":
Hugs last as long as you want them to. It really depends on the situation you are in at the current time. For example, if someone is grieving the loss of a loved one, it would be appropriate to hug someone for a couple of minutes. If you were attending a graduation and were congratulating the graduate, it might be a quick hug.
It really just depends on your relationship with the person you are hugging and the events that are taking place.