Waywordradio attributes the origin to a commercial use that sounds plausible to me:
In the 1930’s, the catch phrase Now you’re cooking with gas, meaning “you’re on the right track,” was heard on popular radio shows at the behest of the natural gas industry, as part of a quiet marketing push for gas-powered stoves.
Stackexchange is more specific. They say:
The phrase has been attributed to Deke Houlgate [by his son], who after working in the gas industry, wrote the line for Bob Hope or maybe for Jerry Calonna.
It was used on a radio program “around” December 1939 and then promoted by gas companies. I can understand putting the phrase in the more-famous mouth of Bob Hope, and he apparently did say it in the 1941 movie The Road to Zanzibar.
Other citations include Lou Holtz and Fanny Brice on Good News of 1940, the 1942 movie The Big Street, and Daffy Duck in 1943’s The Wise Quacking Duck.
The phrase seems to have become popular quickly – a tribute to radio, movies, and the demise of wood-burning stoves. I recall a great-aunt of mine who finally allowed her old wood-burning stove to be hauled away when it was replaced by a combination wood and electric appliance. Only propane would have been available to her but I don’t know if she ever tried that. Perhaps if she’d been cooking with gas she’d have given up the wood-burning oven altogether. She would have made great bread no matter what.