The most common way, presumably, is to close the lid directly or set the "Start screen saver" trigger angle in the "mission control". But generally, there is a time lag between getting the Mac to sleep and going to the screen saver and locking screen (the system defaults to 5 minutes). Unless you set the "Go to sleep or start screen saver" time to "immediate" in the "System Preferences"-"Security and privacy"-"general".
In addition, using Alfred's "lock" keyword can quickly lock the screen. But to do so is to call out Alfred first, input keyword "lock" and enter, to complete the whole process, a bit "not efficient."
Of course, you can also use a third-party application MacID to let the MAC based on your iPhone distance automatically lock the screen, this may be the simplest and fastest way to lock the screen, but because it is a third-party App, the stability of the connection between devices is a major mishap.
If you don't like the previous three ways and want to lock the screen faster and more securely, try OS X's own keychain.
Method
Use Spotlight to search "Keychain Access" (You can also navigate to Finder-application-utility-keychain access to find it), open it.
Then, in preferences (you can use Command +, shortcut keys), check "Show keychain status in menu bar."
Then, click on the "Keychain" small icon in the menu bar of the desktop, "lock screen".
(Tips: In OS X, Command + is the shortcut key for most applications "preferences")