I was reading through the CP9/Enies Lobby arc, Sanji reveals that he has the ability to heat up his legs to the point that anything he touches with the spontaneously combusts. How is it that he got this ability?
Sanji was Red Leg Zeff's disciple. Red Leg Zeff was famous, as his name suggests, because of his red leg. He was known to kill all his enemies using his leg, which used to be smeared with their blood.
Imitating his master, Sanji created his own set of skills. He created the Diable Jambe, in which he rapidly spins and focuses all his energy into his leg, heating it up and forming a red leg which is so hot that anything in makes contact with, spontaneously combusts. After the time skip, he can use Diable Jambe without spinning to make his leg heat up.
How and when he created this technique has not been revealed and is less likely to be revealed. So as @AbhilashK mentioned in comments, he just didn't meet anyone who is strong enough (and/or made him angry enough) to use it till the Enies Lobby arc.