A penalty is a punishment or consequence for doing something wrong, such as having to pay a fee for not bringing your library book back when it was due.
In hockey, players who break the rules have to sit in "the penalty box." Just like the penalty box punishes hockey players, all penalties are punishments for doing something wrong. Going to prison is the penalty for serious crimes. Detention is the penalty for misbehaving in school. Often, penalty applies to payments people have to make for breaking a financial contract of some kind.