Source: via Flickr

Thanks to the IRS's rules on capital gains, you can use the losses you incur from selling underperforming investments to offset your capital gains and reduce your taxable income. As we approach the end of 2015, it may be a good idea to take a look at your portfolio and decide whether you have any losing investments you could do without. Here's what you need to know about tax-loss harvesting, and whether it's a good idea for you.

What is tax-loss harvesting?
Tax-loss harvesting refers to the strategy of selling investments that have declined in value, with the goal of reducing your taxable income.

For example, let's say you invested $10,000 in a certain stock last year and that the value of the investment has declined to $8,000. You can sell your shares and use the $2,000 loss to reduce your capital gains or other taxable income.

The deadline to use a loss on your 2015 tax return is Dec. 31. If your losses exceed your capital gains, you can use up to $3,000 in losses to reduce your taxable income for the year, or $1,500 if your tax status is "married filing separately." However, if your overall capital loss is more than this amount for 2015, you're allowed to carry over the remainder to next year.

Before you sell a stock to reap the tax benefits, there are a few things to keep in mind.

The wash-sale rule
First, you need to know about the "wash-sale rule," which says that if you sell an investment at a loss but reinvest the proceeds in the same (or substantially identical) asset within 30 days, the loss will not be allowed for tax purposes. For example, if you sell an S&P 500 ETF at a loss and buy a different S&P 500 ETF with the proceeds, you can't use that loss.

However, one possible strategy would be to sell one stock or fund, and then buy a similar, but not substantially identical, stock or ETF. For example, if you sell shares of ExxonMobil at a loss and use the proceeds to buy shares of Chevron, you can avoid the wash-sale rule while keeping your exposure to the energy sector and reducing your tax liability at the same time.

When to use tax-loss harvesting, and when it's a bad idea
Tax-loss harvesting can be a good strategy to use, but only in certain scenarios. For example, if you own a stock and your original reasons for investing no longer apply, or the company's growth prospects don't look good, selling to capture the loss, and then redeploying that capital more effectively, may be a smart idea.

However, don't sell promising long-term investments simply for the tax benefits. For example, I own shares in several energy-related companies, such as National Oilwell Varco, Total SA, and Oceaneering. All of these investments have lost a considerable amount of their value over the past year or so, but I still believe in all three companies' future potential. National Oilwell Varco has a leading market share in many of the components it produces, and is one of the most financially solid companies in the sector. Total SA has economies of scale working in its favor, and has done a good job of adapting to lower oil prices. And finally, Oceaneering provides a unique mix of products and services for deepwater drilling rigs, and has also done a good job of managing costs in tough times. So, these would make bad candidates for tax-loss harvesting.

On the other hand, I also own shares in Linn Energy, which has experienced more of a fundamental shift than other energy stocks -- the company's debt has started to become overwhelming, dividend payments have been suspended, and the company's long-term viability is no longer certain. So this is a stock I may seriously consider selling at a loss and redeploying that capital elsewhere.

How much money can you save?
The exact benefit of tax-loss harvesting depends on how much your losses are, and what type of income they are used to offset.

Gains on investments held for one year or less are considered short-term capital gains and are taxed at the same rate as your ordinary income. So if you're in the 25% tax bracket, that's what you'll pay on short-term capital gains. Long-term capital gains are taxed at a more favorable rate, which is 15% for the majority of taxpayers but 0% for taxpayers in the two lowest brackets and 20% for those in the highest.

So the largest benefit is when losses are used to offset short-term gains, but be careful. Losses must be used to offset gains of the same type if possible. For example, if you sell a stock you've owned for five years, any loss you have must be used to offset long-term capital gains. You can only use the loss to offset short-term gains if it exceeds the amount of your long-term capital gains.

For example, let's say you have $20,000 in long-term capital gains, which are taxed at the 15% rate. If you sell a losing investment and realize a $5,000 loss, you'll save $750 on your tax bill.

The Foolish bottom line
Tax-loss harvesting can be an effective way to lower your tax bill or increase your refund, but don't sell stocks that are part of a well-rounded portfolio and have strong growth potential. However, if you're sitting on some losing investments and think that cutting your losses and investing that money elsewhere is the best option, tax-loss harvesting might be a smart move for you.