Both expressions are used when speaking about groups of entities. The difference is that "On average" refers to the characteristics of the the group as a whole while "An average" or "The average" refers to a typical, representative, member of the group.
If we say that "On average students spend 20 hours per week in the Union bar and 15 hours per week in the university library" we are suggesting that if we were to log the times spent by all members of the student body in those places and calculate means, medians or modes for the group (depending on our choice of methodology) then 20 hours and 15 hours would be the result. There would, of course, be some students who spent more time in each place and some who spent less; there might even be some who never went to the bar, some who never visited the library and some, possibly, who never went to either but the average would be what we suggested.
If we say "The average student spends 20 hours per week in the Union bar and 15 hours per week in the university library" this suggests that we can find at least one student who spends exactly those amounts of time in those places. By implication, though, it suggests that we can find many of them, perhaps even a majority who do that. We are also suggesting that students who spend much more time in one of the places and/or much less in the other are, somehow, not typical members of the group.
Saying "The (or an) average..." carries a strong suggestion that a member of the group with the specified charateristic is typical of the group than "On average...". In statistical terms "The average..." suggests the existence of a mode for the dataset which fits the characteristic of a large majority of the members of the group where "On average..." carries no such suggestion.