Kevin O'Leary: Unless you can pass this two-question test, don't buy a home

Kevin O'Leary: Use this test to decide if you should rent or buy a house
Kevin O'Leary: Use this test to decide if you should rent or buy a house

While the classic advice from financial experts and possibly your parents is to figure out how to stop renting and buy a home, you won't hear it from Kevin O'Leary.

Instead, the investor on ABC's "Shark Tank" and personal finance author suggests that people in their 20s avoid taking on a mortgage until they've hit other personal milestones. "I think the key to life — particularly when you're young — is to stay out of debt," O'Leary tells CNBC Make It.

Whether to buy or rent is a "crucial decision," says O'Leary, and in order to help you make the right choice, he offers up this two-question test.

"Are you married?" asks O'Leary. "If the answer is no, rent."

"If you're married, do you have children?" he asks. "No? Rent."

Kevin O'Leary
Scott Mlyn | CNBC

Many financial experts argue home ownership is a way to build wealth, because it gives you equity in an appreciating asset. But O'Leary cautions that homes may not always gain as much value as you expect — at least not anymore and at least not quickly.

"A lot of people say to me, 'If I'm only renting, I'm not building any equity in my home,'" O'Leary says. But, since buying a home usually means taking on debt, it is important to consider changing trends in the interest rates for mortgages, which can be thought of as the price you pay to borrow money.

For the last 35 years, the trend line for the U.S. 10-year Treasury yield, a benchmark for mortgage rates, has been more or less straight down, bottoming out at below 1.5 percent from a 1981 high of around 15 percent.

"Any asset that involves taking debt to own it, like a mortgage, like a house, appreciated in value while interest rates were going down," O'Leary explains. "Well guess what? Interest rates aren't going down any more. Asset classes like real estate stop going up in value when it costs more to borrow the money to buy them."

When you form a family and you're thinking of having, let's say, two kids, that's the time to start thinking about a home.
Kevin O'Leary

Currently, mortgage rates are rising — as of Feb. 1, the average 30-year fixed mortgage rate was 4.22 percent, according to Freddie Mac, the highest it's been in months.

That means a home won't continue to be as safe an investment, or at least not as safe in the short term, he says, so it will be harder to buy and assume you can flip it for a profit.

"Let's say you buy a house for $200,000 and you think 'Oh, gee next year it is going to be worth $250,000!' That might have been true 10 years ago, but I don't think it is going to be true next year, or the year after that, because when rates start going up, and money costs more, and mortgage rates are higher every month, the value of real estate goes flat. Or, often goes down," he says.

Other experts add that the typical return on an investment in residential housing isn't as good a bet as the stock market usually is. So there may be better ways to put your money to work.

This is what a $200,000 home looks like across the U.S.
This is what a $200,000 home looks like across the U.S.

That's why O'Leary says the time to take on mortgage debt is when you're settled in your career and family life.

"When you form a family and you're thinking of having let's say two kids, that's the time to start thinking about a home, because you know for about five to seven years you're going to be raising your children and you need a safe place for them," he explains.

But even then, make sure you can afford it.

While 85 percent of millennials expect to buy a home, a 2017 survey by GOBankingRates found that many young people don't have the necessary savings. According to the survey, 46 percent of young millennials (defined as those aged 18-24) had no money in a savings account. For older millennials (ages 25-34), 41 percent had zero put away.

"You've got to make sure the mortgage payment is only one third of your after-tax income," O'Leary says. "If you're paying more than one third of your after-tax income, you bought a house that was too big and you can't afford it, because there are a lot of other costs in life: education, clothing for your kids, food, maybe you're leasing a car."

The consequences of doing otherwise can be dire: "Don't let it get more than that," he warns, "or you'll find yourself in financial stress, and the first place that plays itself out: divorce."

Don't miss: 'Shark Tank' investor Kevin O'Leary: Here's how to get rich

Like this story? Like CNBC Make It on Facebook!

Why Kevin O'Leary refuses to spend his money on fancy coffees
Why Kevin O'Leary refuses to spend his money on fancy coffees

Disclaimer: CNBC owns the exclusive off-network cable rights to "Shark Tank."