From Apple:
https://support.apple.com/en-us/HT201351Follow these steps:
If you paired an Apple Watch with your iPhone, unpair your Apple Watch.
Back up your iOS device.
Tap Settings > iCloud. Scroll down and tap Sign Out. In iOS 7 or earlier, tap Delete Account.
Tap Sign Out again, then tap Delete from My iPhone and enter your password.
Go back to Settings and tap General > Reset > Erase All Content and Settings. If you turned on Find My iPhone, you might need to enter your Apple ID and password.
If asked for your device passcode or Restrictions passcode, enter it. Then tap Erase [device].
Contact your carrier for help transferring service to a new owner. If you aren't using a SIM card with your device, you can contact them to get help transferring service to the new owner.