How to delete apple id from iphone 5s?

How to delete apple id from iphone 5s? - 1

Reset to factory default settings.

Erase all Content & Settings in the Settings app.

Log out, which may mean you have to log in first to prove you are the real owner.
Resetting or reinstalling firmware does not unlink the phone from the ID database.

It's the basic "anti theft" system and there's no way around it, the real owner must remove the account.

If you bought it locked it's almost certainly stolen. Get your money back.
(And if you "found" it, note that is still classed as theft; "theft by omission").