Xp is is usually decided by the goal, design and testing of the game. There is no predefined rules, it is something that you keep working on as you advance.
Let's say for example you want the player to feel like each level is twice as powerful as the last:
A enemy gives 10XP and has 6HP. Player Damage: Lv1 1dmg, Lv2 2dmg, Lv3 4dmg, Lv4 8dmg. Exp needed follows the same pattern: Lv1 10xp, Lv2 20xp, Lv3 40xp, Lv4 80xp.
Lv1 player kills enemy in 6 hits, Lv2 3 hits, Lv3 2 hits -oops. Now my goal is messed up; I am not getting what i want. So I change the enemy HP to 8 because it is a power of two.
Lv1 8 hits, Lv2 4 hits, Lv3 2 hits, Lv4 1 hits.
Good so damage is what I want now, except when I test the game I notice something: Lv2 defeats 1 enemy to level. Lv3 2 enemies, Lv4 4 enemies, Lv5 8 enemies.
Meaning it took exactly the same amount of hits to reach level 2 as it took to reach level 5. This means I missed my goal, the player feels as weak as in the beginning.
This happened to me in one of my first RPG games, using larger and more complex numbers. Players felt that they weren't really leveling up. I fixed it by reducing the amount of XP needed for the next level. It was something that could only be fixed by testing what amount of XP felt right.
Maybe if you can tell us what the goal of leveling up is, for you, we can help you find a formula.