ERISA is the federal law that governs 401k plans. Under ERISA, a 401k participant can leave his or her 401k assets to a non-spousal beneficiary even if the 401k participant is married. However, the 401k participant must make the non-spousal beneficiary election by whatever form the 401k plan requires. In the 401k plan's beneficiary designation form it will have a section for spousal consent that must be signed by the spouse and notarized.
ERISA requires that all married 401k participants obtain spousal consent to elect a non-spousal beneficiary for any ERISA-governed plan, such as a 401k or defined benefit pension. Any non-spousal beneficiary election made before or during the election is invalid without contemporaneous spousal consent. That means any election prior to the marriage is invalidated upon marriage and must be re-elected when the 401k participant marries. Non-spousal beneficiaries must be re-elected when the married participant reaches age 35 by completing another beneficiary designation form with spousal consent. WIthout valid spousal consent on a valid beneficiary designation form submitted to the plan, the spouse will be the sole primary beneficiary of the 401k participant's benefits.