Hopefully you already know this – if you have a loan from your 401(k) plan and you leave employment, either on your own or if you’re terminated, the loan is considered a distribution from your plan, and therefore taxable. It’s important to note – this only applies when you leave employment.
Here’s an example: you have a 401(k) plan with a balance of $200,000. You wish to take a loan from the plan in order to pay for your child’s college tuition – and so you take a total of $20,000 from the plan. It’s your intent to pay this off over the course of the next couple of years with the proceeds from some appreciated stock – you were delaying the sale of the stock since the stock is poised to run up quickly in the next year or so. Unfortunately, two months later your company decides to let you go – downsizing and all, you know.
Rather than calling the 401(k) loan due and payable immediately, the loan is classified as a distribution – meaning that, not only are you out of a job, you’ve got an extra $20,000 of income that will be taxed now, money that you’ve already spent on tuition. If you’re under age 55 (yes, 55, since you’re eligible to take a distribution after age 55 without penalty after leaving employment), the funds will also be subjected to the 10% early distribution penalty. Topping off the fun facts here is that you likely didn’t think to have any additional tax withheld or an estimated tax payment made, so you’ll likely get hit with a penalty for under-withholding of tax when you file.
So what can you do?
Since you have the appreciated stock (or funds from any other source), you can roll over the substituted funds into an IRA within 60 days. This will effectively negate the distribution, and no tax or penalty will be owed. Of course, if you sell appreciated stock you will owe tax on the capital gains – but presumably this is far less than the ordinary income tax on the full amount of the loan. Of course, if this tax is significant you’ll want to either adjust withholding for the remainder of the year and/or make estimated payments of tax in order to avoid the penalty for under-withholding.
You should consider the additional impacts of taking this distribution – see the article Not So Fast! 9 Special Considerations Before Rolling Over Your 401(k) for more details on what you need to keep in mind as you make a rollover from your 401(k).
Photo by John-Morgan
Click the link to pick up a copy of An IRA Owner's Manual or if you'd prefer the Kindle version (and let's face it, ALL the cool kids do!), you can find that at this Kindle version link.Jim Blankenship, CFP®, EA, is an expert in personal retirement, IRAs, and tax issues, with more than 25 years of experience in the industry. Read more from this author

My other book,
And if you've come here to learn about queuing waterfowl, I apologize for the confusion. You may want to discuss your question with Lester, my loyal watchduck and self-proclaimed "advisor's advisor".
[...] After those choices, you also could take a loan from your 401(k) plan (as long as this is available). This would be another option that is tax efficient (in general) but you would need to pay back the loan, and this is a good way to derail your retirement savings. This could also result in taxation of your loan amount if you leave employment. [...]