A 401k plan is a type of deferred compensation plan. 401k plans allow you to defer some of your salary or wages to a retirement account. For traditional 401k plans the contribution is pretax, and for Roth 401k plans the contribution is made on an after-tax basis. Often employers will match employee contributions up to certain point. The retirement account generally invests in mutual funds. The account balance is determined by the performance of the retirement funds in the account. When retirement funds are performing poorly, your account balance falls. When retirement funds are performing well, your account balance increases.
A deferred compensation plan broadly refers to any number of retirement plans that defer the payment of tax to your retirement. These plans generally allow your employer to set aside a portion of your income either on a pretax basis (as is the case with a 401k or pension plan) or on an after-tax plan (as in executive bonus plans or other non-qualified retirement plans).
401k plans are generally best if you think you will be able to make large contributions to a retirement plan and your employer offers a matching contribution to the 401k plan. A deferred compensation (other than a 401k plan) is ideal if your going to be paid less in income, and your employer will make all (or most) of the contributions towards your retirement.
A 401k plan does have limitations. While contribution limits are high ($16,500 as of 2011), there is a limit to the amount you may contribute. If you think you will contribute more to a retirement plan than this, the 401k will impose unnecessary limitations on your ability to save money. A deferred compensation plan may allow higher contributions, especially in the case of non-qualified deferred compensation plans. This is because a non-qualified deferred compensation plan does not have any contribution limit.