Did Homo erectus invent fire?
Of course, no human being “invented” fire as fire is a natural phenomenon. Instead, we should talk about the earliest controlled use of fire by human beings. In other words, when did human beings start being able to have fires at a time and place of their choosing?
There is much scholarly debate on this issue, as can be seen in the two links below. The earliest use of fire that is accepted by essentially all scholars is from 400,000 years ago, but others claim to have discovered human use of fire up to 1 million years ago.
However, this is somewhat irrelevant to your question because all of these earliest evidences of fire are connected to Homo erectus. Therefore, to the best of our knowledge today, Homo erectus was the first species to use fire in a controlled way.