iOS updates are free to download. Whether you can update to iOS 5 depends upon what the device is and whether it supports that version (e.g. the iPhone 3G can can only be updated iOS 4.2.1) - you can also only update to the highest that the device supports, so if it can have iOS 6.0.1 on it then you can only update to iOS 6.0.1, you can't update to an iOS 5 version
To update, connect the device to your computer's iTunes and copy any purchases off if to your computer via File > Transfer Purchases (File > Devices > Transfer Purchases on iTunes 11). You may also want to copy photos and any important documents off the device as well e.g. via the file sharing section at the bottom of the device's apps tab when connected to iTunes, via wifi, email, dropbox etc - they should be included in the backup, but it's best to have a copy of them outside of the backup just in case. You can then force a backup of the device by right-clicking the 'Device' on the left-hand side of iTunes and selecting 'Backup'.
Then start the update by selecting the device on the left-hand side of iTunes (on iTunes 11 you can enable the left-hand sidebar via option-command-S on a Mac, control-S on a PC), and on the Summary tab on the right-hand side clicking the Check For Updates button
Updating to iOS 5+ : http://support.apple.com/kb/HT4972