Since 1998, most people haven't had to worry about owing taxes when they sell their home, even if they clear a hefty profit when they do so. There's no longer any need to buy another house to roll over any gain, and in many cases the taxpayers don't even have to report the sale of their homes on their tax returns.

You can still owe tax on some or all of the gain from the sale of your home, however. Tax will be due if one or more of the following are true.

1. You didn't own and live in the house for two of the last five years
If you sell your home at a gain before two years are up and you don't qualify for any of the exceptions, you pay tax on the gain.

Exceptions: If you have to move because of health, a job transfer, or other unforeseen circumstances, you may still be able to exclude your gain. The maximum amount you can exclude will be prorated.

For example, let's say you were single and you owned and lived in a house for one year before you were transferred by your employer to another state. You met the requirements for 50% of the two-year time period. You can exclude up to $125,000 of gain from the sale ($250,000 times 50%.)

2. The house appreciated in value when you were not living in it
Prior to 2008, you could have a vacation or investment home for years -- decades, even -- and watch it go up in value. So long as you moved into it for two years before you sold it, you could exclude up to the maximum amount of gain. That loophole has been closed. You cannot exclude gain from while you were not living in the house. For this purpose, the house is assumed to have gone up in value the same amount every year while you owned it.

3. The house went up in value more than the exclusion amount
It's not far-fetched, especially in some parts of the country. The amount of gain you can exclude from the sale of a home is $250,000 ($500,000 if filing jointly). A home can go up in value more than $250,000, or $500,000 if you are filing jointly. You'll pay tax on the gain over that amount.

4. It wasn't your main residence
The rules for excluding gain on the sale of your home only apply to your main residence. If you have a second home or any other home or investment property, you may owe capital-gains tax when you sell.

5. You or your spouse already took an exclusion within the last two years
You can't take this deduction more often than once every two years. This rule can catch people unawares, especially if one spouse sold a home before they got married. In that case, you'll want to wait until two years after the sale before you sell another house at a gain.

Excluding a gain on the sale of a home is still one of the best deals in the tax code -- when you meet the requirements. Make sure you stay within the rules, if possible, to avoid any surprise gain when you file your return.