Q: I need to buy some new bond investments. I'm torn between longer-term Treasuries and tax-free municipal bonds. Which should I choose?

If you are investing in an IRA or other tax-advantaged account like a 401(k), it never makes sense to buy tax-free bonds. Money withdrawn from tax-deferred retirement accounts is taxable as ordinary income, no matter how it was invested within the account.

Assuming that you're investing in a taxable brokerage account, the answer is a little more complicated. Generally speaking, tax-free municipal bonds pay lower interest rates than taxable bonds of the same maturity length and credit quality. What you need to determine is whether the tax advantages make up for the lower rate.

Here's a simplified example. Let's say that AAA-rated tax-free bonds with 30-year maturities yield 2.5%, while a 30-year Treasury bond yields 3%. If you're in the 12% federal tax bracket, this brings your effective yield from the Treasury bond down to 2.64%, so it would still be the better option. On the other hand, if you're in the 22% federal tax bracket, it makes your effective Treasury yield just 2.34%, so the tax-free bond would be the better choice.

State taxes could make the benefit even better. (I ignored state taxes for this comparison for simplicity, as states have differing income tax structures, and some municipal bond income is tax-exempt in its own state, while some is not.)

The Motley Fool has a disclosure policy.