You can only update a device to the highest iOS version that it supports, which for an iPhone 3GS is 6.1.6
If your phone is already on iOS 5+ then you should have a Settings > General > Software Update option on it for direct update. If not then you can only update via your computer's iTunes
Updating to iOS 5+ : http://support.apple.com/kb/HT4972
Whichever way you do update then first copy your purchases over to your computer's iTunes library via the File > Devices > Transfer Purchases menu option and take a backup - and preferably take your own copy of any important photos and/or documents that you have on it.