There's a fairly complicated formula to exp, but the general rule is you earn 1 exp for attempting an attack (i.e. You miss or you deal 0 damage), you earn 10 exp for a successful attack (i.e you dealt 1 or more damage), and you earn 30 exp for killing an enemy (i.e. your attack reduces the enemy's HP to 0). These do not stack, however, since exp is awarded at the end of the encounter - if you attack an enemy twice and the second attack kills them, you will only earn 30 exp.
Also, the higher your characters level is, the less exp they will earn when fighting the same level enemy - for example, if your level 9 character kills a level 10 enemy, they will get 30 exp, but if a level 19 character kills the level 10 enemy, the amount of exp earned will be reduced from the normal 30.
Healers now get 20 exp for using the Heal staff instead of 10 exp in previous games, which means they level up quicker than previously, but they also learn less exp when using the same staff as they level up - e.g. A level 5 healer using Heal will earn 20 exp but a level 15 healer using Heal will earn less than the normal 20 exp.