I had a problem where UFW is blocking apt-get, ping and so on.
I found this thread, and here is the correct solution (that is working on ubuntu 14.04):
The order is important:
ufw reset ufw allow git ufw allow out http ufw allow in http ufw allow out https ufw allow in https ufw allow out 53 ufw logging on ufw default deny incoming ufw default deny outgoing ufw limit ssh ufw enable
Now apt-get is working with ufw!