Each Carrier has theretheir own process for this. My carrier is US AT&T, to find my carriers instructions I Googled "AT&T device unlock" and was immediately led to this page. I could post links to more carriers device unlock pages but that list would never be complete for a worldwide audience. The correct page for your carrier is most likely not hard to find via Google.
FWIW, usually the original customer must request the device unlock, someone who has already purchased a phone from a private party would not be able to request the unlock without help from the original owner.
As mentioned briefly in another answer, carriers lock devices to their network and will not unlock them until the original contract has been completed. What's actually happening is the carrier is discountinghas discounted the initial cost of the phone. This discount means the carrier would havesuffer an immediate loss if the customer simply cancelled and sold the phone. The lock to the network ensureensures the customer can't do that. Once the terms of the original contract have been met the carrier will unlock.