Before you sell or give away an old iPhone, Find My iPhone, which works in conjunction with Activation Lock (Apple's anti-theft system) needs to be deactivated from your iCloud account. This also applies if you've lost your passcode and are locked out of the device, if you're restoring to a previous iTunes backup, or just want to remove it from your list of iCloud devices.
This, of course, only applies if you actually activated it in the first place.
You can deactivate Find My iPhone on the device by going to Settings -> iCloud -> Find My iPhone and toggling it off. Alternatively, you can also just turn off iCloud altogether.
However, if you don't have the iPhone anymore or can't access it because of a lost passcode, the new user won't be able to activate the iPhone, you won't be able to get back in, or you might not be able to restore to a previous iTunes backup. Luckily, there's a way to disable Find My iPhone remotely from a computer or other iOS device.
This also applies to iPads (Find My iPad) and iPod touches (Find My iPod).
Method #1: From a Computer
This will not work from the web browser on an iOS device; the desktop version of iCloud.com is not mobile-friendly. You may be able to, but YMMV.
Step 1: Turn Off Your Device
The iOS device needs to be offline in order to complete the process, so make sure it's turned all of the way off before proceeding. If you gave it to a friend or family member, ask them to turn it off for you.
Step 2: Go to iCloud's Website
In your web browser on your computer, navigate to iCloud.com and sign in using your Apple ID information.
Step 3: Open Find iPhone
Click on the "Find iPhone" icon from the presented iCloud apps once you've signed into your account.
Step 4: Select Your Device
Towards the top of the next page, click on "All Devices" and select the device you want to disable Find My iPhone on.
Step 5: Turn Off Find My iPhone
Option #1: Erase iPhone
If you gave the device to somebody else to use on their own cellular service, you'll want to "Erase" it from the device information window that pops up, which will effectively remove Find My iPhone and Activation Lock in the process.
If you lost your passcode, you will also have to select "Erase iPhone," as there's no way to get back into it without factory resetting it or restoring it via iTunes.
Follow the on-screen instructions to continue erasing, and since the device isn't lost, you don't need to enter a phone number or message.
Option #2: Remove from Account
If you gave the iPhone to somebody else and already erased it, but they still can't activate it for some reason, then select "Remove from Account" instead of "Erase iPhone," which should resolve the issue.
Also choose this option if you don't have the device anymore and just want it gone from your iCloud list of devices.
If you don't see the above screen when you select the device, you can alternatively remove it by clicking the X icon next to the device's name under the "All Devices" dropdown menu.
Click "Remove" to confirm the process on the final popup. As it states, the device can now be activated by another person. If you do have the device still, removing it won't do anything really, as it will just reappear in Find My iPhone whenever the device connects to the internet again, according to Apple.
Method #2: From Another iOS Device
If you have more than one iOS device, Find My iPhone can also be disabled remotely using the Find My iPhone app. All you have to do is launch the app, sign into your Apple account, select the offline device, then tap either "Erase iPhone" from the bottom or "Remove" from the top-right corner, then follow the on-screen instructions to continue.