Your retirement accounts get special tax treatment so that you can have a comfortable old age. If you tap them, however, before you turn 59 1/2, you usually pay a 10 percent penalty on the withdrawal on top of regular income tax. If the IRS garnishes your account to pay tax debt, there's no penalty. If you take the money out to pay a tax debt, that's another story.
The IRS lists several exceptions to the 10 percent penalty on early withdrawal, such as spending the money on high medical bills. Taking money out to settle with the IRS isn't on the list. It's still legal to take the money out, but you will pay income tax and penalties on it. If you've inherited an IRA and have to start making mandatory withdrawals, there's no penalty no matter what you spend the money on. You do still pay tax though.
A Roth IRA is a special case because you fund the account with after-tax dollars. When you tap your contributions, there's never a second tax bill. You pay tax on the earnings, however, if you take them out before age 59 1/2. IRS rules assume all your withdrawals come from contributions until you've exhausted them.
Some 401(k) plans allow for hardship distributions. You can withdraw your money without a penalty, provided you show you have an "immediate and heavy financial need" for the cash and no other way to get money. Alternatively, if your plan allows you to borrow against your account, you can take the loan without any tax, as long as you pay it all back. The rate is lower than you'd typically get from a commercial loan, and all the interest goes back into your 401(k).
If you receive a defined-benefit plan such as a pension or annuity, you may be able to tap it early. You may not have to pay tax on the whole amount -- IRS Publication 575 details how you figure the tax -- but whatever part is taxable is also subject to the usual 10 percent penalty. Like 401(k) plans, your pension plan may allow you to tap it early with a loan instead of a withdrawal.