Press the Windows key + L to lock the computer.
Open Screen Saver Settings by clicking the Start button , clicking Control Panel, clicking 'Appearance and Personalisation', clicking 'Personalisation', and then clicking 'Screen Saver'.
Select the 'On resume, require logon' check box, set a time after which to start the screen saver, and then click Apply. (Choose a wait time that's not long enough for an unauthorised person to use your computer, but not so short that if you are idle for a moment, the screen saver locks your computer.)
If Fast User Switching is turned on, select the On resume, display logon screen check box.