Why does a myelagram cause headaches and how long does this last?

CSF leak. Like an lp, a myelogram involves introducing a needle into the fluid-filled sac that contains the spinal cord. If the hole created by the needle does not close, spinal fluid can leak out and cause a headache that is worse with standing and better with lying down. If this describes your headache, try lots of fluids and caffeine. If this fails, a procedure called a blood patch can plug the hole.
Loss of CSF. When a myelogram is proformed some CSF is removed and this changes the pressure on the brain. This is thought to cause the headache but we are not sure. Best to stay flat in bed immediately after study to avoid headache. Usually worse if you stand after study. Can last for few hours to days.