Several ways and there is a lot of good information over at the XDA forums for this. I am no expert and (sigh) am not responsible for anything bad that may happen to your phone.
1) If you want to root your phone (tons of threads on how to do this - there is an app called OCLF from the Market that is for lagfixes, but can just root your phone too), you can use Titanium Backup from the Market to backup all of your apps+data. Then you can connect your phone to your computer and copy the entire Titanium Backup folder to your computer. You'll want to backup your contacts too if you have any. After that, you can reset your phone to factory conditions (settings > privacy > Factory Data Reset). Then, going into Settings > SD Card you can unmount your internal card and reformat it. Make sure you take out your external card before you send it in.
As always, there is some danger in deleting something you didn't want to delete, and there is some danger in rooting your phone, so please read up on. Once you get your new phone, you'll need to root it and enable sideloading, which is a little tricky to do (
How to Enable Sideloading of Apps on Captivate - Android Forums). You'll need to do this to get your apps+data that you backed up from Titanium Backup.
2) There is an easier way. Go to Appbrain.com on your computer and setup an account - connect your phone and follow the directions. It will tell you to load a couple of apps onto your phone so it knows what apps you have installed. You can sync everything with appbrain. Then follow the instructions on how to wipe your phone. When you get the new one, install appbrain apps back on your new phone and re-sync it. I would do this over Wi-Fi since you will have to download all of your apps again. This does not require you to be rooted, but it does not keep track of all of your data either this way.
3) My way - combo of 1 and 2. This is summarizing everything. Root your phone, download Titanium Backup and save your apps and data and copy that folder to your computer. Use the appbrain option to keep track of your apps. When you get the new phone, reinstall apps from app brain and then restore your data through Titanium Backup.