If you purchase your iphone (anywhere including the apple store) with a singed 2 year contract, especially if you pay less than the MRSP of the phone, it is most likely locked.
If you pay full price for iphone at the apple store without signing any contract, it is most likely unlocked.
If you purchase your iphone (used) from Kijiji, then it might be locked it might not be locked. It might also be hard locked.
If you purchase your iphone from any carrier, it is most likely locked and you have to pay to have it unlocked.