Created by an employee within the scope of employment, or
That fall within one or more of the nine statutory categories, where an agreement commissioning the work is in writing and signed by the creator or creators before work begins.
The nine statutory categories include: contribution to a collective work; part of a movie or other audiovisual work; a translation; a supplementary work; a compilation; an instructional text; a test; answer material for a test; or an atlas
If a work doesn't fit within the statutory definition of a work-for-hire, the employer may still own it if the author assigns the copyright to the employer or contractor.
An author-owner is free to assign copyright to anyone, so a written contract can change these basic rules. As an example, many publishers require assignment of copyright as a condition of publication