iOS 4.0 supports a very rapid secure erase called "Data Protection". If you upgrade from 3.0 you need to do a restore to set the stage for hardware encryption of all the data.
If your device isn't capable of hardware encryption (often called secure data at rest), then you can use the Erase all content and settings function. This built-in functionality to secure wipe your iDevice has been around since iPhone OS 2.0
As this doesn't work the same way on all iOS devices, do read Understanding 'Erase All Content and Settings' before you depend on this to clear data securely.
Once you are through erasing the device, you might want to connect it to a clean iTunes library and restore the device and set it up as new. Making a new account on your Mac or PC is an easy way to have a library with no account, no songs, and no apps just to be sure the device has a clean (and easily verifiable) start to it's new life.