A prepayment penalty is sometimes included in a mortgage contract as a deterrent to someone paying off a home loan early. The purpose is to protect lenders against a financial hit when a borrower immediately sells or refinances, thus paying off the loan, according to Investopedia.
Though prepayment penalties aren't included in all mortgages, having one makes it more difficult for a homeowner to affordably refinance, according to Investopedia. Some penalties, called hard prepayment penalties, are applied whether the homeowner sells the home or refinances the loan. Others, called soft prepayment penalties, are only applied when the homeowner refinances the existing mortgage. Penalties are typically a percentage of the loan balance.