If you go to System Preferences > Security & Privacy > General.. you will see the first option to check - 'Require password ... after sleep or screen saver begins.'
Then whenever you put your mac to sleep it will lock and require login to wake up.
You can also assign Sleep to a Hot Corner so, when you simply move your cursor all the way to one corner it will go into sleep mode (and, be locked if you set up sleep lock above).
See.. System Preferences > Desktop & Screen Saver > Screen Saver.. & look for Hot Corners button.