Typically you need to keep the money in the plan until you reach age 59 ½. Withdraw any of it before then and you'll be hit with a bruising 10% early withdrawal penalty, on top of the regular income tax that is due on withdrawals from all traditional defined contribution plans. Bad idea.
There are exceptions, however. The IRS waives the 10% penalty for certain "hardship" withdrawals. Each plan's rules vary (check yours to be sure), but you may be able take money out of your retirement account penalty-free before age 59 ½ if you use it for:
Don't count on it, though. This money is locked up until retirement for a very good reason: If you spend it now, you risk jeopardizing your financial security when you're older.
If you can't get the money anywhere else, your best option is probably a loan. Many defined contribution plans allow you to borrow against the amount in your account. You must repay the money to your account within a set period - usually a few years - or the loan is treated as a withdrawal, meaning you'll owe taxes and a 10% penalty on it.
There are three main drawbacks to taking out a loan. First, you reduce the money you have growing for your retirement years. Second, you have to pay interest on the amount you borrow - typically the prime rate plus one percentage point - though you do pay the interest to yourself. Third, you must repay any outstanding loan within a few months if you are laid off or decide to change jobs.