
In the Keyboard Shortcut field, press Control-F9 (press the Control key first, hold it down, then press the F9 key), then click Add. For Application, choose All Applications. Under Application Keyboard Shortcuts -> All Applications, click the "+" sign (lower left corner) to add a shortcut.
Start System Preferences (/Applications/System Preferences). The next part of this hint involves assigning a keyboard shortcut that will activate the Lock Screen option of the Keychain Access menu extra. If you click on the Keychain Access menu extra that should have appeared in the menubar (it looks like a tiny lock), you can try pressing the "Lock Screen" option: this will, as you'd expect, lock the screen. Now close the Preferences panel and then the Keychain Access application. Make sure "Show Status in Menu Bar" is enabled. Open the Preferences panel (menu: Keychain Access->Preferences). Open the Keychain Access application (/Applications/Utilities/Keychain Access).
So I worked out the following method to enable a keyboard shortcut that locks the screen in OS X - and no scripting or work in the Terminal is required. I'm a keyboard shortcut junkie, and I quickly became envious of the Ctrl-Alt-Del-Spacebar combo that I could use in Windows XP to swiftly lock the screen (muscle memory is a great thing). I use both an iBook and a Windows-based laptop at work, and it's a must for me to lock the screens on both machines before leaving my desk.