Your machine will always check its local cache first to save having to ask a DNS server a question that it already knows the answer to. You can see this by opening a command prompt and running the following command:
if your machine cannot get an answer from your DNS cache, it will ask it's primary DNS server, which will in turn check it's own database and give you a reply. For home users, it is most likely your router. You can find your DNS server by running the following command:
If there is no reply from your primary DNS, your computer will ask it's secondary DNS (if you have one configured) and then it's third and then it's fourth.. and so on.
If your primary DNS is online but doesn't have the answer, it will in turn ask it's own primary DNS (probably your ISP for most home users). Your ISP will then check its own DNS and serve a reply to your router which will serve it to you.
If your ISP DNS doesn't have the record, it will start asking it's configured roots or forwarders. These are a list of places configured inside DNS that are used when the DNS server itself doesn't know where to get an answer from. These are typically other DNS Servers, or internet root name servers.
How DNS query works
Domain Name System - Hill Associates
DNS Namespaces - Google (particularly look at the Namespaces section)
Diagnosing DNS problems
Some applications store their own DNS cache. Web browsers are a prime example of this. As there are billions of applications in the world, millions of which (possibly) store a DNS cache - I'm not going to start listing possible ways to flush it. If you suspect an address is being cached - prove it (example - chrome fails to resolve a site name but Firefox is OK - it may be a chrome cache issue) and then google how to clear cache for that specific application.
NSLOOKUP www.google.com - this command (when entered into a command prompt) will give you a DNS lookup for www.google.com and return its ip:
IPCONFIG /flushdns - this command will flush your local DNS cache and help get rid of any bad results you have stored locally
Lastly, if you are getting poor name resolution or lots of lookup failures from your ISP, there are loads of alternative DNS servers you can add to your router or PC to do name resolution more reliably. Although I use my corporate DNS servers and ISP for most of my stuff, the google DNS service is pretty good. Check out this link for more info
(lastly, apologies for the poor screenshots - I'm at work and can't post better ones without blanking out most of the data - I found these on the net)