Force system to use local hosts file before DNS (OS X El Capitan)
This is already the default in OS X. I.e. if you specify a host name in the hosts file, lookups will use the IP address you've specified there instead of doing a DNS lookup.

Note that this is only true for programs using the system standard resolver functions. Programs can use their own resolving mechanism that is not guaranteed to honor anything you write in the hosts file. However, those programs should be rare and far between.