Why doesn't a pencil write if its tip is heated in a candle flame?
The lead (I'll call it lead for brevity even though it isn't made from lead) in a pencil is a mixture of graphite and clay pressed then sintered.
A candle flame is nowhere near hot enough to chemically change the lead. The clay requires many hundreds of degrees to sinter further and the graphite doesn't burn until getting on for 2000K. So the heat from the flame is utterly inconsequantial.
However if you put the pencil into the yellow part of the flame there will be hydrocarbons present, and these will adhere and form a film over the surface of the pencil lead. This film acts as a lubricant so when you try to write the tip of the pencil just slides over the paper instead of abrading to leave a trail of graphite.
I note the comments report mixed results from the experiment. Getting the effect is very dependent on where in the flame you put the pencil. Too high in the flame and there will be no unburnt hydrocarbons left.
To fix the problem just wipe the tip of the lead with any mild abrasive to remove the hydrocarbon layer.
The reason must come from the hardening it experiments under fire.
Pencils' leads (the writing core) are made today of a mixture that contains clay (see for example this patent) which hardens under the heat, but mose importantly, the compound will loose the softness because of the separation of salts under the heat.
The mixed results come from the fact that there is no unique definition of the mixture and different manufacturers will use different ones. But you should expect that soft leads, which seem to have larger content of clay, will be more affected by heat.