It appears in his poem "The Last Man" (1826), although the exact phrasing might be slightly different in the original context.
It's important to note that there's some debate about the exact origin of the quote, and some sources attribute it to other authors. However, Campbell's poem is the most widely accepted source.