Measure the length of one side of the headboard. Measure out an equivalent length of nail head trim. Cut as close as possible to the total length, snipping just past a nail hole using a pair of wire cutters.
Position the trim in place along the edge of the headboard. Push a nail through the first hole in the strip of trim and pound through the fabric and foam into the headboard using a rubber mallet. Continue pounding nails through each hole and into the headboard, adjusting the trim to lay straight as you go.
Position an extra nail head past the end of the nail head trim strip and pound into place with the mallet. Repeat this process until the nail heads reach the desired turning point.
Cut the trim strip to the length of the next edge of the headboard with the wire cutters, being sure the strip starts and ends with a hole. Continue attaching nail head trim around the perimeter of the headboard until the desired trim effect is achieved, filling in gaps with extra nail heads as necessary.