actually this is wrong.
iOS 6.1.3 is the highest system version on iPhone 3Gs. iOS 7 is not supported for iPhone 3Gs. So if you try to upgrade your iPhone, 6.1.3 will be signed and installed to your device.
Once you upgraded, you will not be able to downgrade from 6.1.3 to 5.1.1 since 5.1.1 is not signed any longer. However, you can try to jailbreak your iPhone at 5.1.1, back up your shsh files. If shsh files are backed up, you can find some "hacked" ways to downgrade from 6.1.3 to your current system. But that will take tons of time if you are not familiar with that process.
I owned an iPhone 3Gs, and 6.1.3 is running just fine, not smoothly but worked fine.
Oh right, always back up your iPhone with iTunes before upgrade.