At first, people cooked on outside wood fires - there weren't very many people, so there was plenty of wood to burn, and people spent most of their time outside anyway. When people left Africa, about 60,000 years ago, they brought the idea of cooking fires with them all over the world.
But by the Late Stone Age, around 6000 BC, people were beginning to live in houses, and the houses were in small villages. They needed to be more careful with their wood supply, to make it last. They started to use ovens. Also, they began to make fired pottery around this time, which needs very hot and long fires in a kiln (a sort of oven).
By 4000 BC they started to cook on charcoal fires, instead of just using wood. You make charcoal by slowly burning wood in a kiln with very little air- this half-burned wood is charcoal. It burns more efficiently and hotter than wood (You use charcoal today in backyard barbecues).
Blacksmiths needed even hotter fires to smelt iron. The method was not invented until about 1500 BC, by the Hittites in West Asia, and then it spread to the rest of Asia and to Europe from there. African blacksmiths may have invented iron smelting for themselves, about 300 AD.
The Romans, beginning around 200 BC during the Roman Republic, used charcoal fires to heat air and water and piped it through their houses to heat their houses and to get hot water for public and private bath buildings. But most people used small charcoal fires in clay braziers to heat their houses and to cook on at home.
Monks chopping wood
In the Middle Ages in Europe, these pipes went out of use, and people went back to wood or charcoal fires on hearths in their houses. They did start to use chimneys to get the smoke out of their houses. At the same time, in the Islamic Empire in West Asia and North Africa, people kept on using hot water pipes to heat rich people's houses and public baths, and clay braziers for small fires.