score:5
The simple answer is that yes, they do sometimes need a visa. The details obviously vary, but there is no general exemption or tradition that would allow heads of state to go everywhere in the world without visa or authorisation.
Case in point: The US A-1 visa as explained on travel.state.gov. Amusingly, government officials cannot travel on official business under the Visa Waiver Program, even if they come from a country whose citizens do not need a visa to enter the US for other purposes. Heads of state or government (but not other officials) also automatically qualify for this A-1 visa, no matter the purpose of their trip.
In fact, there is at least one president who is wanted by international courts and basically cannot leave his country except to a handful of friendly countries or under the cover of the diplomatic immunity conferred to heads of state on official businessβ¦