Research article inspired by a question on MSE?
Assuming that you weren't the original source of the question, then it is entirely proper that you mention and cite it.
Interesting mathematical questions can come from anywhere and from anyone. But if you are inspired by the thoughts of another person, then hey should get credit for that.
Ideally a citation should point to a real person, though anonymity on SO may make that impossible.