Exorcism

You attempt to force a ghost, demon, or other such outer-planar entity to leave the host or object it is possessing. The creature that the entity is possessing must either be willing or restrained for you to cast this spell.

After an hour of reciting chants and waving burning sage about, the netity must make a saving through using either Charisma, Constitution, or Wisdom (depending on its choice).

If the entity fails its saving throw, it takes 5d12 psychic damage and its hit point total is reduced by that amount. It must then make a second saving throw, using the same attribute as the first. If that roll fails, it also loses a number of points from that attribute equal to your spellcasting ability modifier. Hit point and attribute reduction lasts for one week.

If the entity fails its first saving throw, you must make a Constitution saving throw (DC equal to 10 + the creature's Charisma modifier + its proficiency bonus). If you fail, you take 2d12 psychic damage.

If you reduce the creature's hit point total to 1 (or if its score is reduced to less than 3), it will be too weak to remain inside its vessel and will attempt to flee.