Mark where you want the rows of buttons to go on the piece of plywood that is the size you want your headboard to be with chalk. You can have your buttons spaced as close together or as far apart as you like.
Drill a small hole with an electric drill through each chalk mark. Flip the piece of plywood over and drill in a small screw 1 inch beneath each hole.
Cut the sheet of foam so that it is 4 inches longer and wider than the dimensions of the headboard using an electric knife. Flip the foam over and spray it with industrial strength fabric spray.
Press the foam against the plywood, adjusting it so the plywood is in the exact center of the foam. Pull the edges of the foam down taut against the back of the plywood. Staple gun these edges of foam down against the back.
Lay your king-sized sheet face down on a flat surface. Lay the plywood foam-side down on the fabric, in the exact center. Pull the edges of the sheet down over the back of the plywood, staple gunning them down. Cut away the excess with shears.
Thread an upholstery needle with strong thread in a matching color as your sheet. Sew upholstery buttons against each hole. Pull the thread down against the back of the plywood, wrapping the thread and knotting it against the nail. This keeps the button yanked down against the foam, creating a nice tufted appearance. Once you've sewn your last button your headboard is ready to hang.