Imported from the Apple Support Forums via the Wayback Machine 🔗
First you must turn off Find My Phone. Then sign off from your Apple ID on the phone. Connect the phone to your computer and use iTunes to Restore it as a new device.
If the phone is online then you may be able to do all of this from your iCloud.com account.