How to stop getting XP (World of Warcraft: Legion)

If you don't want to get any more experience points and stop leveling up, it's actually possible to freeze your level bu heading to Stormwind or Orgrimmar. There are NPCs there which will let you turn off experience point gains by paying 10g. This makes it possible to experience old content at the correct level, and not having to worry about outleveling anything.

For Alliance, the NPC is called Behsten and is located in Stormwind Keep.

For Horde, the NPC is called Slahtz and is located in The Valley of Honor.

If you want to gain XP again, talk to the same NPCs and pay another 10g to turn it on.