Being laid off (except when you are aged 55 or over) is not one of the exceptions to the early withdrawal penalty for a 401(k) account.
However, there is an exception for emergency personal expense up to $1,000 once a year.
Please read this TurboTax Help article for more information.
You are allowed to withdraw funds from a 401k plan at any time for any reason if you are separated from the company (retired, quit, laid off, it doesn't matter.) You always pay regular income tax on the withdrawal. If you are under age 55, you will also pay a 10% penalty. There are a few exceptions to the 10% penalty, but just being laid off is not one of them. The exceptions that might apply to you include, excess medical expenses while unemployed; paying COBRA medical insurance premiums, and a $1000 hardship exclusion. The other exceptions are listed here.