The following steps are intended for the Apple iPhone 4 and 4s running any iOS.
Tap the Settings App
Tap General
Tap Reset
Tap Erase All Content and Settings
Tap Erase iPhone
Tap Erase iPhone to continue.
Type in your Apple ID password, then tap Erase.