If you got an iPhone or iPad from another user or if you are giving away your iDevice to someone else, it makes sense to delete your Apple ID associated with the iPhone/iPad completely. Erasing all content and resetting the iPhone is one way but here's a complete method that lets you remove all traces of your Apple ID from your iPhone.
The following tutorial is a beginner tip. If you are a new user or looking for a checklist of things to do before selling/giving away your iPhone/iPad, this will be useful.
How to Delete/Remove your Apple ID Completely from the iPhone and iPad
The Easy Method: the easiest way is to remove everything from your iDevice. To do this, all you have to do is go to Settings → General → Reset → Erase All Content & Settings. Then, Settings → General → Reset → Reset All Settings.
The other method for Deleting Apple ID from the iPhone/iPad
#1. Remove Find My iPhone: the first thing you have to do is remove Find My iPhone from your device. This is the one that triggers the Activation Lock so you have to get this out of the way. If you have enabled Find My iPhone, here's how you can remove it: Settings → iCloud → turn off the switch for Find My iPhone.
#2. Remove Your Device from iCloud: Now, follow this tutorial here to remove this device from your iCloud Find My iPhone account too. If you are selling/giving away the iPhone/iPad, it is going to be setup as new on another Apple ID. It makes sense to remove the device from your account.
#3. Sign Out Everywhere: Go to Settings → iTunes & App Store and tap on the Apple ID field. Then, tap on Sign Out. Next up, go to Settings → iCloud and repeat the process. These are the two usual places where you have signed in with your Apple ID.
#4. Reset: Finally, don't forget to reset. Erase all content and settings from Settings → General → Reset and then for good measure, Reset All Settings too.
You might also want to remove the device from iTunes backup in case you no longer need it (the backup file occupies a large chunk of the harddisk space). You can do this by heading over to “Edit → Preferences → Devices” in iTunes (on the computer).