Set up screensaver password and hot corner for OS X
Locking your computer whenever you leave it is a great security habit, and with a couple of steps, your OS X system will lock with a quick move of the mouse. These instructions are applicable to most Mac OS X versions. The details of configuring this setting for different versions of OS X may differ slightly.
First, we want to configure the screen saver to require a password. To do this, open your system preferences and select the "Security" icon:
Mac OS X system preferences security icon
In the security panel, check the box next to "Require password immediately after sleep or screen saver begins."
Mac OS X security panel screensaver password box
Now use the back arrow to go back to the main system preferences and select the "Desktop & Screen Saver" icon.
Mac OS X system preferences screen saver icon
In the Desktop and Screen Saver panel, click on the "Hot Corners" button:
Mac OS X desktop panel hot corner
Pick a corner of the screen that you'd like to use to activate your screen saver. In the pull-down menu next to that corner, select "Start Screen Saver."
Mac OS X hot corner selection
Now to lock your computer, just move your mouse cursor to the corner you have selected. Lock your computer whenever you leave it unattended.