The simile of the head being on fire is in quite a few suttas. I’m not sure which one you are referring to above. However, SN56.34 is pretty clear with what this means with regard to right effort.
“Sir, if our clothes or head were on fire, we’d apply extraordinary enthusiasm, effort, zeal, vigor, perseverance, mindfulness, and situational awareness in order to extinguish it.”
The Buddha is encouraging us to bring the above attitudes to extinguishing our internal fires.