Buying a house is a big decision and potentially a good way to build wealth — if you're smart about it. That's why "Shark Tank" star and finance guru Kevin O'Leary says you have to ask yourself these two questions before taking out a mortgage.

According to O'Leary, question No. 1 is, "if you lose your job for more than six months, do you have a way to be able to afford the mortgage, yes or no?" O'Leary tells CNBC Make It.

"Very important," so if the answer is no, don't buy the house, O'Leary says. You're not ready.

Indeed, experts recommend maintaining an emergency fund that's liquid and accessible, and has enough money to cover six months of living expenses, which as a homeowner would include your mortgage payments.

The second thing you need to determine is whether you're buying a house you can actually afford. So, ask yourself, will the mortgage payment cost more than one-third of your after-tax salary?

"If your mortgage costs you more than one-third ... you bought too much house," O'Leary says "That's a big problem."

Courtesy of Kevin O'Leary

O'Leary's "Shark Tank" co-star (and real estate mogul) Barbara Corcoran recommends using a similar rule of thumb: Aim to spend about 30 percent of your take-home pay on housing costs, she says. However, Corcoran says that 30 percent should cover all homeownership costs — not just your mortgage — including mortgage interest, taxes, insurance, maintenance and any renovations you want to make. According to the U.S. Department of Housing and Urban Development, those who spend over 30 percent of their income are "cost-burdened," which means they might have difficulty paying for necessities like food and medical care.

"[A mortgage] is probably going to be your No. 1 debt in your life. It is for millions of people," O'Leary says. "So it really garners serious consideration."