As you fight with your heroes, they grow in experience and level up. Does a hero lose the experience gained during that match if he or she gets defeated (life reaches 0)?
Yes, this appears to be exactly the case. See this thread:
PSA: The death penalty in Fire Emblem Heroes is a loss of any xp or level ups gained for that unit in the map.
Camilla died on a map after leveling to 11. Even though the rest of the team completed the level, she was lvl 10 in the next map.
Also, you can't "reroll" bad level ups with this method. You'll get the same stat growths next time you level, you just lose the xp.