I can’t track down any quotation that sounds like that imputed by your question, but I’d recommend reading the Wikipedia article on Marxism and religion as a starting point.
[Religion] is, at one and the same time, the expression of real suffering and a protest against real suffering. Religion is the sigh of the oppressed creature, the heart of a heartless world, and the soul of soulless conditions. It is the opium of the people.
Marx’s view of religion was complex and nuanced. He saw it in many respects as necessary in our society, to provide comfort and consolation for people living hard and difficult lives, and to be an expression, a reaction or protest against the harshness of their lives:
The last sentence is often remembered, but not quite fully understood: opium in Marx’s day was not merely the evil, addictive drug we consider it today. It was a medical treatment for severe pain, but also dangerously addictive in excess, with addicts coming to prefer the lassitude of addiction to actually doing anything about their suffering. With this, Marx was saying that people who are suffering need the “medical treatment” of religion to ease their suffering, but that religion, thus used, often became a damaging substitute for eradicating the cause of suffering.
Marx believed that if people could see through their “addiction”, they would set about fixing their real problems:
The criticism of religion disillusions man, so that he will think, act, and fashion his reality like a man who has discarded his illusions and regained his senses
(Here, the word “disillusions” means dis-illusions, i.e., “removes the illusions”. Marx was unnecessarily flowery in his language).
While he uses the phrase “the abolition of religion”, it’s not clear that he actually means banning religion. He calls “the abolition of religion”
the demand for … happiness … [the] call … to give up a condition that requires illusions.
This may be read as saying that, once people decide to do something to improve their lives, to get rid of poverty, disease, etc., religion will no longer be necessary. Interestingly, it appears that many fundamentalist pastors have read Marx, realising that the continuance of their faith requires that they be seen as victims, thereby teaching their congregations that they are under attack when they are in fact very privileged.
Marx in fact had no problems with the spiritual side of religion. He believed that, once the desperate addict’s need for religion as a painkiller for their living conditions was removed, people would
develop in greater spiritual freedom … cease to be the slaves of the body … have time at their disposal for spiritual creative activity and spiritual enjoyment
So that’s what he had in mind for a post-suffering, post-religion society: a society that could attend to its real spiritual needs.