To lock the dock and prevent any accidental drag & drop to move the dock icons, type the following commands in the terminal:
> defaults write com.apple.dock contents-immutable -bool true
> osascript -e 'tell application "Dock" to quit'
To unlock it, change the value from 'true' to 'false' in the first line of command.
Source: http://forums.macosxhints.com/showthread.php?t=67085