The origin of the fire lies with Gandalf. After Thorin and company escape the goblins in the mountain, they are continuing on their journey when they hear the Wargs (wild wolves) around them. In order to avoid an encounter with the Wargs, Thorin and company climb up into the trees (Bilbo needs a bit of help from Dori). Although Wargs speak their own language, Gandalf can understand them, so he hears about their plans to join the goblins in raiding nearby villages. That is when Gandalf grabs a pinecone, sets it on fire, and throws it at the Wargs. He does that again and again, which sets the Wargs on fire, who then run around, howling in pain and setting the surrounding trees on fire. When the goblins arrive, they start building fires around the base of the trees that Thorin and company are hiding in, attempting to smoke them out. They only manage to escape because the Eagles swoop in and save them.