A certificate of deposit (CD) account can be an appealing option for people who want a risk-free place to put their cash while earning more interest than a savings or money-market account can offer. However, CDs (also known as time accounts) require a commitment to leave the money deposited for a certain length of time. If you need to withdraw money from a CD before the agreed-upon date, then you'll most likely face a penalty.

First, check your bank's policy on early withdrawals
Generally, early withdrawals on a CD are penalized as a certain amount of interest, depending on the term length of the CD account.

For example, Wells Fargo (NYSE: WFC) uses the following penalty schedule:

CD Term

Early-Withdrawal Penalty

Less than 3 months

1 month interest

3-12 months

3 months interest

12-24 months

6 months interest

More than 24 months

12 months interest

Minimum penalty amount

\$25

On the other hand, Ally Bank (NYSE: ALLY) uses a slightly different schedule:

CD Term

Early-Withdrawal Penalty

2 years or less

60 days interest

3 years

90 days interest

4 years

120 days interest

5 or more years

150 days interest

The first thing you need to do is check your bank's policy on early withdrawals. Also be sure to check whether the penalty is calculated based on the amount of money you withdraw early or on the total balance of the account.

Calculating the early-withdrawal penalty
Because financial institutions compute interest and assess penalties in different ways, it's tough to use a set formula to determine an early-withdrawal penalty. With that in mind, here are a few scenarios and the formula to use with each one.

Scenario 1: If your bank assesses the penalty only on the money you withdraw and calculates the penalty on a monthly basis (like Wells Fargo), then use this formula:

For example, if you withdraw \$5,000 early from an 18-month CD with a 1.00% interest rate, the penalty would be:

Keep in mind that many banks have a minimum penalty amount. In Wells Fargo's case, it happens to be \$25, so if the calculated penalty is less than this amount, you'll still be assessed a \$25 penalty.

Scenario 2: If your bank calculates the penalty as months of interest, but on the account's entire balance, then modify the formula as follows:

Scenario 3: If your bank calculates the penalty on a daily (not monthly) interest basis, then the above formulas can be modified accordingly:

As another example, Ally doesn't allow partial withdrawals, and it calculates penalties based on daily interest, as you can see in the chart above. If you have a five-year, \$10,000 CD at 1.50% interest and choose to redeem the CD early, then your penalty will be:

It's also worth noting that any accumulated interest on the account will be used to offset the penalty. If the penalty is greater than the interest your account has earned, then the remainder will be deducted from the principal.

Why do CDs have early-withdrawal penalties?
CDs generally pay higher interest rates than savings and money-market accounts offered by a particular bank. The penalty is in place to protect the bank so that deposits that the bank is counting on for a long period of time don't suddenly become short-term deposits -- and to compensate the bank if they do.

While it can certainly be annoying to pay a penalty, the fact of the matter is that, with the current low interest rates, it's relatively cheap to withdraw money from a CD early if you need it, especially compared to other types of accounts with early-withdrawal penalties (such as retirement savings).

This article is part of The Motley Fool's Knowledge Center, which was created based on the collected wisdom of a fantastic community of investors. We'd love to hear your questions, thoughts, and opinions on the Knowledge Center in general or this page in particular. Your input will help us help the world invest, better! Email us atÂ knowledgecenter@fool.com. Thanks -- and Fool on!

The Motley Fool owns shares of and recommends Wells Fargo. The Motley Fool has the following options: short January 2016 \$52 puts on Wells Fargo. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.