To follow these instructions you must have jailbroken you iPhone or iPod touch. You can find instructions on how to do that by following the iClarified Jailbreak Wizard
Press to launch Cydia from your Springboard
Press to select the Sections tab from the bottom of the screen.
Press to select System from the list of Sections.
Tap to choose Lockdown from the list of Packages.
Press the Install button at the top right of the screen.
Press the Confirm button to begin installation.
Press the large Restart SpringBoard button.
Press to launch Lockdown from the SpringBoard.
When launched for the first time Lockdown will ask you to input a safety word and a password. Input the secret word and pin of your choice then press the Continue button.
Lockdown will now show you a list of the applications you have installed on your iPhone. Press to select an app you would like to password protect then press the large Lock button.
You can do this for as many applications as you like...
Press the Home button and return to the SpringBoard. Now try to open an application you locked. Notice you need to enter your pin password before the application will open!