Unless a cellphone is purchased as unlocked, the provider selling the phone to a customer can unlock it for free; there are no other legal means for unlocking a phone for free. However, the provider does not unlock the cell phone until the customer has fulfilled the terms of his service contract. The FCC notes that the CITA adopted standards in 2014 that require service providers to unlock cell phones if certain obligations of the buyer are met.
Generally, providers who sell cellphones to their customers do so at a discounted rate or may even give the customer the phone in exchange for agreeing to a service plan. Usually, the service plan is 2 years or so in length. Most have a clause for early termination that allows the customer to buy out of the agreement beforehand. In this case, some providers may go ahead and unlock the phone if the customer is buying out of the agreement early.
Prepaid phones carriers may also unlock the phones that they sell, but they may also only unlock the phones after customers have had the phone for 1 year and have completed any usage requirements during that time. This is true with most prepaid cellphone service providers.