A headache is commonly associated with malaria, to the point that it is considered an important presentation that can aid with diagnosis.
The headache here is likely caused by cytokines – specific inflammatory proteins released by the body in response to the production of waste and toxic chemicals. This causes inflammation, which can help to combat the infection. However, it can also affect the brain, causing the brain to become inflamed therefore resulting in a headache.
There are other reasons for headache though too. Headache can result from dehydration for example, as this causes the brain to shrink and thereby pull away from the inside of the skull resulting in pain.
Likewise, headaches can be the result of malaria treatments.