A two-year-old boy has narrowly escaped serious injury after a house fire in Sydney's west.