Well Newton says an object at rest will stay at rest and an object in motion will stay in motion until an outside forces acts upon it. The use of the headrest is to reduce whiplash once in an accident. Since you're in your car moving forward and you car stops you will continue to move forward the outside force is hopefully your seatbelt yanking you back your headrest is there to cushion you head and keep your head from lashing all the way back and causing brain damage.