It's a good idea to lock your Mac computer with a password. After all, your Mac can contain your personal files and photos, plus access to your email account.
To create a password for logging in, click Finder > Security & Privacy then click the General tab at the top. Here, you can set a password that must be entered before you can use your Mac at login and when waking up from sleep mode or from the screensaver.
Set time before password is needed
Select the checkbox for Require password after sleep or screen saver begins and choose Immediately from the dropdown menu.
Finally, select the checkbox for Disable Automatic Login.
If you ever want to change your password, you can do so in this same menu.