Generally, the exception for using retirement funds in an individual retirement plan to build or purchase your first home does not apply to a distribution of your elective deferrals from a 401(k) plan.
Elective deferrals to a 401(k) plan are subject to certain distribution restrictions. See Publication 560 Retirement Plans for Small Business, Publication 575 Pension and Annuity Income and Tax Topic 424 401(k) plans.
If you are under the age of 59 1/2, a distribution (including a distribution of employer matching and profit sharing contributions) from your 401(k) plan is generally subject to a 10% additional tax on early distributions. There may be special rules, for example, if the distribution is from a designated Roth account or after you reach age 55 and separate from service. This 10% additional tax is in addition to other taxes that apply to the distribution.