What factors determine the need for lumbar puncture in patients with fever and headache?