Sync iPhone with iTunes on computer will back up iPhone. Also if on iOS 5 or 6, you can back up to iCloud also. Then to erase the iPhone, Restore iPhone on computer with iTunes, at end just remove it, do not restore from back up or you will place all your stuff back on it. Or you can just simply tap Settings App > General > Reset > Erase All Content and Settings, that erases everything too.
I plan on selling my phone. I have the 32gb 3gs. I dont want to loose all the data thats on the phone such as passwords in the password app, or contact information etc.
How to BackUp
... , when I do sell the phone how do I keep the data thats on it from being passed along to the buyer?
ERASE / Clear All Data
Go to Settings > General > Reset > Erase all content and settings