Experience is awarded based on the amount of points you get in each match you play, which is in turn made up of all the points you get in each round. The more points you score, the higher your experience.
However, there is a conversion rate. Just because you got 200 points in an Execution match doesn't mean you'll get 200XP. Instead, the conversion rate makes it more like 100.
*For the record, I don't know the conversion rates, so the above example is probabaly incorrect*
In order to get the most out of your points, you should play King of the Hill/Annex, as you respawn. That way you can continue to gain points/experience through each round, whereas in other game modes, once you die you no longer gain points (duh). The conversion rate might be smaller, garnering you less experience per point, but you'll score more points. On average, I get several thousand points more in KotH/A matches then in something like Execution or Guardian. Because everyone respawns continuously, you can kill many more enemies and get more points/experience.
Level 5 is relatively easy to get, even if the rest of your team is very good, as continuous respawns of enemies means there is always someone to kill.