In the game the fire is an accident - a lantern knocked over when Ellie is struggling with David. But in both the game and episode, at this point David is more concerned with killing Ellie than saving himself (and he half-believes that he is now infected now from Ellie’s bite).