In most cases the license is not transferred. The license is attached to the company, so whoever buys the company gets the license. But there's a caveat to this, which I will explain.
What you essentially do is you don't buy the license, you buy the company. When a licensed company changes hands, that is called a change of control. And here is the caveat: the order in which you do things matters.
In many jurisdictions, most U.S. states and the United Kingdom for example, you cannot complete the purchase first and tell the regulator later. You sign the purchase agreement, and then you file with the regulator for approval of the change of control before the deal closes. The agreement is conditional on that approval. Only once the regulator says yes do you close the deal and take over the company.
In other jurisdictions it works the other way around. You buy the company, the change of ownership is recorded on the corporate register, and then you notify the regulator within a set number of days. You need to know which of the two applies to you before you sign anything.
Either way, this does not absolve you from the requirements. A license can't simply be handed to a new owner. The new owner has to go through a mini application process, just as the previous owner went through a full application process.
Long and short, due diligence will be done on you. Enhanced due diligence will be done on the new owner. If that is okay, the license is simply updated with the new owners of the company. That is how a license is essentially transferred.
Once the change of control is done, it is also recorded at the corporate level, on the corporate register, at the state or federal level, depending on which country you're registered in. It says this company used to belong to this owner, and now it belongs to this new owner.
So you don't buy a license, you do a change of control, and the change of control mechanism can vary in each country and for different types of licenses. Always consult a lawyer or a consultant to understand what the process may be. Especially ask whether approval comes before or after closing, what the nuances are, how long the timelines take, and what happens if something like X or Y happens. How will a delay be handled, and so forth?
The one question people should always ask: what if the regulator decides not to approve the change of control? If approval comes first, do I get my deposit back and walk away? If I've already bought the company, do I lose the license, etc.? I think it's very important for you to have an answer to that question before you sign.
On the cost side: in most cases, for a money services business doing a change of control, there is no cost involved other than a very small state fee, or enhanced due diligence fees charged by the regulator. The costs have already been paid by the original license holder. There may be attorney fees or other external fees, but as far as the state or the issuing authority is concerned, there is usually no fee for this.