Open the file /etc/modprobe.d/blacklist as root in a text editor:
Add this line to the end of the file:
The next time Ubuntu boots up pcspkr will be blocked from loading and you will no longer hear the beep. Peace and quiet at last!
But if you only need a temporary solution to disable the beep, just run this command (as root):
modprobe -r pcspkr