If the device was purchased unlocked or has been officially unlocked by the carrier to whom it was locked, ugprading will never lock it.
If the device has been hacked or jailbroken to unlock it, then it is almost guaranteed that upgrading will relock it to the original carrier and possibly brick the device.
If by upgrade you mean the firmware, then: Connect to iTunes. From the summary screen select "Check for Updates"
if by upgrade you mean to the iPhone 5, then you need to simply go and by a new phone form the apple store or contact your carrier for options they may have.
selling an iPhone 4 on eBay or other similar sites is very straight forward