Poe wrote it in his Marginalia, but it seems he didn't invent this saying himself.
It's written in Poe's Marginalia, which were originally published variously but can be found collected together in some editions of his complete works. This particular quote is from an item of marginalia which has been designated as number 168 or as number 119 of his Marginalia, which I quote in full as follows (emphasis mine):
All true men must rejoice to perceive the decline of the miserable rant and cant against originality, which was so much in vogue a few years ago among a class of microscopical critics, and which at one period threatened to degrade all American literature to the level of Flemish art.
Of puns it has been said that those most dislike who are least able to utter them; but with far more of truth may it be asserted that invectives against originality proceed only from persons at once hypocritical and commonplace. I say hypocritical - for the love of novelty is an indisputable element of the moral nature of man; and since to be original is merely to be novel, the dolt who professes a distaste for originality, in letters or elsewhere, proves in no degree his aversion for the thing in itself, but merely that uncomfortable hatred which ever arises in the heart of an envious man for an excellence he cannot hope to attain.
This was first published in Godey's Magazine and Lady's Book, Vol. XXX (1845). I found it by searching Google Books for
puns "those who most dislike" with results restricted to the 19th century. Interestingly, Poe's overall introduction to his Marginalia also makes another quip about puns:
It may be as well to observe, however, that just as the goodness of your true pun is in the direct ratio of its intolerability, so is nonsense the essential sense of the Marginal Note.
More interestingly, it seems that although modern authors frequently attribute this quote to Poe, and perhaps he was indeed the one who first phrased it exactly like that, he is clearly not coining a new phrase here: he writes "it has been said", suggesting a claim that was already known at the time of his writing. I found another source which says:
A celebrated author says "Nobody dislikes a pun but he who cannot make one." So say I; for it stands to reason that one defective in that ready wit which is necessary in the punster will not like to hear another capable of doing that which he knows himself incapable of.
This comes from the article "On Punning" written by an author given only as "T.H.B." in the magazine *The Satchel: a Repository of Wit, Whimsies, and Whatnot (Volume 9, 1831) - predating Poe's 1845 piece of marginalia. But the identity of this "T.H.B.", and of the "celebrated author" that they quote, remains a mystery. I tried to search the web for the phrase
"Nobody dislikes a pun but he who cannot make one", and came up with only this one source.