Usually with great difficulty. The easiest way is to buy an iPhone "factory unlocked" from Apple. In your case it all depends on the history of your iPhone: What carrier was it locked to? Who owned it before you? Did they pay all their bills? Is there time remaining on their contract? If you have the "right" answers to these, and other questions I haven't thought of, the original carrier might unlock it for you for free. Then again they might not.
There are companies that advertise they will unlock your phone for a fee. Some are legit but some are scams and, depending on where you are, some could be illegal.