To remove your Apple ID from a device you no longer have, use a web browser to sign in to your Apple ID account on a computer or another device, go to the device list, select the old device, and choose Remove from Account, or use iCloud.com/find to erase and remove it remotely. This disconnects the device from your account, stopping access to iCloud and Apple services on that old hardware, even if it's offline.
Remove a device
Only the person who owns the Apple ID—or has access to the password—can remove it. If the iPhone still has someone else's Apple ID, you'll need to contact them or return the device.
When you sign out, any information stored in iCloud remains available in iCloud. That information will be removed from your device unless you choose to keep a copy of that data when prompted.
On your iPhone or iPad
Here's a step-by-step on the responsible recycling of your old iPhone:
A: No, factory resetting your iPhone will not remove your Apple ID. However, it is important to disable the Find My iPhone feature and sign out of iCloud before performing a factory reset.
For iPhone, you might be able to remove Activation Lock on the web even if your device isn't offline.
Each Apple device is linked/associated with an Apple ID of the person who did the setup. Activation Lock prevents anyone who is not the owner from using this iPhone. To unlock the Phone, you need the Apple ID and password of the previous owner, that were used during set up. So you have to contact the previous owner.
On account.apple.com, select Devices and remove any devices associated with your Apple Account that you don't recognize.
View and remove your devices that are associated with your Apple Account for purchases
When the device is erased, tap Remove This Device, then tap Remove. All your content is erased, Activation Lock is turned off, and someone else can now activate the device.
You can also erase your iCloud account without a password using iTunes, If you have access to a computer with iTunes installed. This method allows you to restore your device to its factory settings, effectively removing your iCloud account from the device.
Apple iOS: Strongest Native Protection. Apple uses hardware-based encryption. After a factory reset, the encryption key is deleted, rendering the remaining data unreadable.