It would be nice if you could finance your retirement entirely from Social Security benefits and the income you receive from your investments (typically as dividends from stocks and interest from bonds). Unfortunately, most retirees will need to sell off at least a small percentage of their investments each year to cover the gap between income and expenses. The question is, which investments should you sell to get that money?

Selling by account type

Most retirees will have investments tucked away in several different types of accounts: tax-deferred retirement accounts such as IRAs and 401(k)s, the Roth versions of same, and likely a standard brokerage account as well. If you held exactly the same investments in each of these three types of accounts, the base returns would be identical but the amount of money that would make it into your pocket would vary because of tax differences.

Dividends and interest in standard brokerage accounts are taxed as soon as they come in, and you'll get hit with capital gains taxes when you sell investments in these accounts at a profit. Investments and income in traditional IRAs and 401(k)s can grow tax-free (which includes being free of capital gains taxes), but as soon as you take the money out, you'll be required to pay income taxes on it. And Roth distributions are entirely tax-free. Thus, taxes should be a major consideration when deciding which account to sell from.

If possible, leave your Roth accounts alone as long as you can – the more the investments in this account are allowed to grow, the more you'll save on the (tax-free) eventual distributions. However, if selling the investments you need for income would generate an excessive tax bill for the year, you may need to take a portion of these funds from your Roth account just to keep your tax expenses at an affordable level. If you're not sure how to juggle your distributions for tax purposes, consult with a CPA or EA (enrolled agent) for guidance.

For example, consider the case of Ron the Retiree, who has a traditional IRA with $400,000 worth of assets, a Roth IRA with $100,000 and a standard brokerage account with $50,000 ($30,000 of the latter is long-term gain). Ron needs to withdraw $40,000 per year to meet his income needs. If he gets his annual income by selling stocks from his standard brokerage account, he'll get hit with a long-term capital gains tax of 15% of the gain, or $3,600, but he won't owe income taxes on the money. If he takes all the money from his traditional IRA, there's no capital gains tax but he will pay income taxes of $5,738.50 (using 2017 tax brackets) on it assuming he has no  other taxable income. And if he takes the money from his Roth, he'll pay no taxes on the withdrawal. Ron could also split up his withdrawals, taking part of the money from each type of account, to manage his tax bill without depleting too much of the Roth account's assets.

Smashing a piggy bank

Image source: Getty images.

Selling by investment type

When the stock market suffers one of its periodic crashes, the instinctive reaction is often to "cut your losses" and sell out of your stocks. However, this is the absolutely worst time to sell – the market is at its bottom, meaning that you'll be buying high and selling low. Instead of trying to time the market, choose which investments you sell based on how your investments are split between stocks and bonds to keep an appropriate percentage of each. One useful trick for calculating the right asset allocation is to subtract your age from 110 and use the result as the percentage of investments you want to keep in stocks.

For example, let's say Ron is 70 years old and his investments are split 50-50 between stocks and bonds. 110 minus 70 is 40, so he should ideally have about 40% of his investments in stocks and 60% in bonds. In this case, the best move would be for Ron to sell enough stocks to reach the desired 40%/60% allocation. If selling that much stock produces more money than Ron needs for income that year, he can take slightly less and use part of the extra funds to buy bonds so that his account reaches the correct allocation.

Other considerations

Certain factors can complicate your buying and selling decisions further. For example, once you hit age 70 1/2 the IRS will require you to take a certain minimum amount from your tax-deferred accounts each year, including 401(k)s and traditional IRAs but not Roth IRAs . Failing to do so means you'd be hit with an enormous tax penalty, so this distribution is nonnegotiable. Thus, once you reach the required age your investment selling must start with your tax-deferred accounts; only if you need more money than the RMD calls for should you then turn to your other accounts.

If you plan to leave a large chunk of your investments to your heirs, then the best course of action is to leave your standard brokerage account untouched. When your heirs inherit these accounts, the basis in those investments "resets" to the current fair market value. In other words, even if those investments had greatly increased in value since you bought them, your heirs can sell them immediately without having to pay capital gains taxes. For example, Ron has $30,000 of gain on the investments in his $50,000 brokerage account. If he dies and leaves those investments to his son Robert, then Robert would be considered to have zero gain on those assets. He could sell the investments the next day for $50,000 and owe no taxes on the transaction.

Juggling the various factors can get very tricky, which is why a financial advisor with experience in retirement accounts can be an extremely useful resource. After all, whatever fees you end up paying him you'll likely earn back in the money you save thanks to his advice.

The Motley Fool has a disclosure policy.