Jailbreaking is a process of removing the enforcements imposed on an Apple iOS so thatthir4d party applications can be installed to it.
Unlocking is a process of removing the network restriction on a device so that any other GSM network can be accessed through it.
If you need to use T-Mobile SIM card on a network locked iPhone, It is necessary to be unlocked. Jailbreaking is not a must. Jailbreaking may also void your warranty. You can unlock an iPhone without jailbreaking using remote unlocking service. You can get the remote unlocking service for an iPhone from Theunlockarena.com at affordable cost with easy unlocking guide. Good luck mate.