A spinal headache can happen as a result of procedure where a needle goes into the fluid-filled space around the spinal cord, such as a spinal tap (lumbar puncture) or epidural block (such as that performed during a woman's labor and delivery). Spinal fluid could leak out, changing the pressure around the brain and spinal cord. If enough of the fluid leaks out, you could get a spinal headache.
It's rare after a spinal tap or spinal anesthesia, but more likely when a larger needle is used for an epidural and it accidentally passes through the covering of the spinal cord.