A domain name is first purchased thru a Domain Registrar.
At the time you sign up for the domain, you're asked to submit your personal information, and information on 2 or more Name Servers. This information is stored on a 'root DNS server'.
When someone searches for your domain on the web or using any other service that needs to get hold of details on your domain, these root servers are queried. An exception is when you cache the DNS information locally.
Now, the root DNS server returns your domain's Name Server information to the requester. The Name Server in turn provides the requester the requested information.