If you'd like to prevent against unauthorized access to your Windows 10 user session while you are away from your computer, you can set up your computer to request a password every time your computer resumes from Sleep or Standby.
Automatically Lock Windows 10 PC When Away
Click on Start > Settings > Accounts and go to Sign-in options > Require sign-in. Click on the drop-down menu located below If you've been away, when should Windows require you to sign-in again? and select When PC wakes up from sleep:
The next step is to choose after how much idle time the Sleep mode will come into play. Go to Settings > System > Power & Sleep and configure your sleep settings: