If you forget about JB for a minute when you upgrade your firmware in the ideal situation it will just do an upgrade everything will remain the same. You will have your data, apps, settings etc. In rare cases there are snags that require you to reload the firmware and in this case you will lose everything because it will reload it fresh. This is rare but it does happen, however if you right click the iPhone in the left column of iTunes you can backup, transfer purchases and sync which will save everything within iTunes. If you do need to restore it will prompt you whether you want to restore from your last backup and this will put everything back the way it was before the phone was reloaded fresh.
JB, if you do an upgrade you will lose your JB including apps, data, customization etc. There are some apps that allow you to back that stuff up but I've never used it so I couldn't tell you about that. When you do a JB there are different tools. If you use a tool like GP it does the JB without reloading the firmware so everything will remain how you have it now after the JB but you should still do a backup and transfer purchases before you start the JB process. If you use a tool like pwnage tool you have to restore from a custom firmware which means reloading the firmware however again if you backup in iTunes you can restore from your backup. In conclusion it's very hard for you to lose your data, settings, etc. if you sync and/or backup regularly.
I use iClarified site regularly go into the tutorials, search for my name I've linked to it a bunch of times. You may find that sometimes the links are dead however so you may need to search if it's been awhile since the tool has been out. I believe there are links for GP in the GP untethered thread.