If it's a rather basic phone just swapping the SIM may work. If that doesn't work it needs "unlocking" which you can usually get done unofficially at tech stores.
If it's a fairly advanced phone it may not work fully until you contact the new phone company and get them to update the phone.