On Mac OS X Snow Leopard and below it was possible to access the Hosts file using this command:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
In Mac OS X Lion this is no longer possible due to sandboxing.
The best option to access hosts file on Lion is Terminal:
sudo vim /private/etc/hosts
Any terminal editor will do (vi, vim, nano, etc).