Is it safe to tie a scarf tight around your forehead to get rid of the headache? And why does it make my head feel better to do this?

Should be safe. It should be safe, just make sure it is not so tight that it cuts the circulation. The reason it helps is because many of our headaches are tension type headaches, in which muscle spasm may also be a culprit. Tightening the scarf is somewhat like massage and relaxing the muscles so it helps. Other things helpful would be relaxation, meditation and obviously if no contraindications tylenol (acetaminophen).
Yes. Many headaches are better with pressure. The squeezing on the muscles dulls the pain receptors messages to the brain. I would recommend trying homeopathic bryonia for that kind of headache which is better pressure. The scarf is safe as it is ceasing the pressure you need for relief.