This famous quote comes from Martin Luther the reformer. Interestingly, infidels have long used this quote out of context to show that religion and Christianity are contrary to reason, but this is actually not Luther’s meaning, nor is he rejecting reason, but rather, reason divorced from revelation and faith.

The actual quote is

Reason is the Devil’s greatest whore; by nature and manner of being she is a noxious whore; she is a prostitute, the Devil’s appointed whore; whore eaten by scab and leprosy who ought to be trodden under foot and destroyed, she and her wisdom … Throw dung in her face to make her ugly. She is and she ought to be drowned in baptism… She would deserve, the wretch, to be banished to the filthiest place in the house, to the closets.”
[Martin Luther, Erlangen Edition v. 16, pp. 142-148]

And again

But since the devil’s bride, Reason, that pretty whore, comes in and thinks she’s wise, and what she says, what she thinks, is from the Holy Spirit, who can help us, then? Not judges, not doctors, no king or emperor, because [reason] is the Devil’s greatest whore.
[Martin Luther’s Last Sermon in Wittenberg … Second Sunday in Epiphany, 17 January 1546. Dr. Martin Luthers Werke: Kritische Gesamtausgabe. (Weimar: Herman Boehlaus Nachfolger, 1914), Band 51:126, Line 7ff]

But in what context was he making such a statement? Here’s an interesting line from a book by John Osborne entitled Luther.

“And I sat in my heap of pain until the words emerged and opened out, ‘The just shall live by faith. My pain vanished, my bowels flushed and I could get up. I could see the life I’d lost. No man is just because he does just works… This I know; reason is the devil’s whore, born of one stinking goat called Aristotle, which believes that good works make a good man. But the truth is that the just shall live by faith alone. I need no more than my sweet redeemer and mediator, Jesus Christ.”

Remember, Luther was reforming against the unbiblical theological approach of the Catholic church and the pagan approach to knowledge in the Universities of the time, which included its adoption of the Aristotalian view of science and God (which included the earth-centric view of astronomy which later was used by scientists and Catholics to persecute the heliocentric view), and specifically, the idea of dualism, i.e. the separation of the sacred and the secular, reason and faith, the body and the spirit, etc.

What Luther was complaining about was reason untethered from faith and scripture, and how such use of reason can lead man astray. Luther realized that, for instance, secular work could be a God-given calling, just as much as a call to the priesthood. As Nancy Pearcey relates in her book Total Truth:

One of the driving motives of the Reformers was to overcome this medieval dualism and recover the unity of life and knowledge under the authority of God’s Word. They argued that the medieval scholastics had accommodated far too much to pagan philosophers such as Aristotle, and they urged a more critical attitude toward the alleged truths of reason arrived at apart from divine revelation.
[Total Truth, pp. 80-81]

It is plain to see that Luther hated the Aristotalian approach to knowledge, and associated it directly and almost solely with those using ‘reason’ to attack faith, as seen here:

The universities also need a good, thorough reformation — I must say it no matter whom it vexes — for everything which the papacy has instituted and ordered is directed only towards the increasing of sin and error. What else are the universities, if their present condition remains unchanged, than as the book of Maccabees says, 2 Macc. 4:9, 12: Gymnasia Epheborum et Graecae gloriae,[1] in which loose living prevails, the Holy Scriptures and the Christian faith are little taught, and the blind, heathen master Aristotle[2] rules alone, even more than Christ….It grieves me to the heart that this damned, conceited, rascally heathen has with his false words deluded and made fools of so many of the best Christians. God has sent him as a plague upon us for our sins.
[An Open Letter to The Christian Nobility of the German Nation Concerning the Reform of the Christian Estate, 1520 by Martin Luther (1520)]

In the lengthy analysis in Trinity Journal, historian Ronald Frost relates:

Luther’s greatest concern in his early reforming work was to rid the church of central Aristotelian assumptions that were transmitted through Thomistic theology….[]
Despite claims to the contrary by modern proponents of an Aristotelian Christianity, Aristotle’s works offered much more than a benign academic methodology; instead, as we will see below, his crucial definitions in ethics and anthropology shaped the thinking of young theological students in the sixteenth and seventeenth centuries who read the Bible and theology through the optic of his definitions. Luther recognized that Aristotle’s influence entered Christian thought through the philosopher’s pervasive presence in the curricula of all European universities. In his scathing treatise of 1520, To the Christian Nobility of the German Nation, Luther-who for his first year at Wittenberg (1508-9) lectured on Aristotle’s Nicomachean Ethics four times a week-chided educators for creating an environment “where little is taught of the Holy Scriptures and Christian faith, and where only the blind, heathen teacher Aristotle rules far more than Christ.”
[Aristotle’s Ethics: The Real Reason for Luther’s Reformation?]

CONCLUSION
Luther’s position was not that reason was not to be used, but it was to be used within a biblical framework, that is, in subservience to revelation. As I love to say:

Before faith comes, reason is king. After faith comes, reason is servant.