We don't know.
Much, if not most, of what Epicurus wrote has been lost, all we have is fragments. There doesn't seem any evidence for anybody else having said it - an earlier quote along the same lines would prove that Epicurus didn't say it.
It is, as you say, a critic of Epicurus' position that credits him with having said it. It's possible that it might have been invented as a straw-man argument, simply to be destroyed, but I think that highly unlikely. The argument is simply too good. I'd expect that the first person to come up with it must have been pleased enough with it to want to be known as the author.
It is consistent with what we do know that Epicurus said - apart from the anachronistic use of 'god'. Epicurus spoke about the gods, not any particular one, so it'd be odd for him to state it in a monotheistic manner - but we're reading the interpretation by Lactantius, so you'd expect that sort of translation into his perspective.
The other thing that's odd about it is that Epicurus' general position is that the gods only exist because people believe in them and have nothing to do with human affairs. With that position, it isn't clear why there need be any 'problem of evil', for Epicurus to address. Maybe there's some early, missing, work in which he explores the position of a monotheist and develops this position.
In translations of Epicurus, the word 'evil' crops up, but it is usually liked to pain, in apposition to 'good', which is liked to pleasure. The complicated Christian view of evil that, no doubt, Lactantius would have held, is rather a long way from that.
If we consider the statement re-cast into Epicurus' terms, it would be something like:
Either the gods wish to abolish pain, and cannot; or they can, but do not want to. If they want to, but cannot, they are impotent. If they can, but does not want to, they are wicked. If the gods can abolish pain, and the gods really want to do that, why is there pain in the world?
I think that Epicurus position would be simply that the gods are impotent and don't have no interaction with, nor interest in, human affairs, so the question is pretty irrelevant. There is pain in the world because that is the way the world is. The gods wouldn't want to abolish it, if they could even think of the notion, and, having no interest in humanity, they'd not want to.
So it'd only be in answer to a fairly simple-minded, or foolish, notion that Epicurus would be bothered to ask the question. Epicurus, living 300 odd years BC, wouldn't have met any Christians, or Muslims, of course, since there weren't any, but he might have met some Jews, one of whom might have raised the question.
Maybe, some day, somebody will discover some more writings of Epicurus that help answer the question, but this isn't very likely. I think 'we don't know' is the best position. On balance, I think it possible that he'd have said something like the above, but highly unlikely that he'd have said it in the form in which it's quoted.