CNBC's Jim Cramer hasn't recommended bonds since the 2008 financial crisis because interest rates have been so low.

But that's not to say bonds have no place in a portfolio. In fact, he says they play an essential role in investing, especially as investors get older.

"In general, for the last few years, even when the stock market has been getting absolutely pounded, bonds simply haven't represented very good values versus equities," the "Mad Money" host said.

Cramer has always had the notion that excessive prudence can be one of the most reckless strategies of all. A heavy investment in risk-free U.S. Treasury bonds guarantees a very low return on an investment. For those who want to grow their capital, stocks are the only game in town.

Stocks are a tool to make money, Cramer said, and bonds are for capital preservation — for protecting money and providing a small, steady return that can offset the impact of inflation.

"Depending on how old you are, there is a huge difference in how you should approach the very idea of putting your money in bonds," Cramer said.

Cramer believes many financial experts tell their clients to own bonds a lot earlier in their lifetime than is really necessary. An investor will likely not get rich from only owning Treasury bonds.

Even in a 401(k) or an Individual Retirement Account, Cramer recommends that younger investors weigh their investments very heavily toward stocks, particularly because these types of accounts will allow investors to avoid capital gains or dividend taxes. That means gains can compound, tax-free, year after year.

However, as investors grow older, owning Treasury bonds becomes absolutely essential because bonds are simply safer. So, once investors have used the stock market to make themselves financially independent, they should put more money into U.S. Treasuries for protection.

How much of a retirement portfolio should be kept in bonds versus stocks? Cramer broke it down by age:

20s: None

30s: 10% of your retirement fund; 20% if you are conservative

40s: 20% to 30% bonds

50s: 30% to 40%

60s: 40% to 50%

Post-retirement: Increase bond exposure to 60% to 70%

"You're going to be living off your investments for the rest of your life, so some part of your portfolio should always be trying to create more wealth in case you live longer than you expect and need more money to support yourself," Cramer said.