Penalty is the punishment imposed on a wrong doer. It can be in the form of imprisonment or fine. It can refer to a sum of money that is exacted as a punishment for either a wrong to the state or civil wrong. Generally penalty is used in the context of crimes but it can also be imposed for civil wrongs at times.
Penalty can also refer to an extra charge against a party who violates a contractual provision. For example prepayment penalty is a charge assessed against a borrower who elects to pay off a loan before it is due.
Penalty can also be the stipulated damages a party to a contract should pay in case of breach. It is the sum of money the party agrees to pay or forfeit by way of punishment in case of breach of the contract. However if the penalty provided in the contract is excessive, the court may refuse to enforce it.