Analysis: What's Up With the Title?
Whitman decided that he liked the first line of his poem so much that he would use it as his title. He likes to repeat himself, and the repetition of the title and the first line adds to the chanting quality that is so characteristic of his work. As we have mentioned elsewhere, "learn'd" is almost like a slap in the face to the astronomer. He describes what we can only imagine to be a refined, sophisticated scholar using a contraction that indicates the voice of a plain person – an average Joe.
In the 1967 edition of Leaves of Grass, the poem stands alone by itself, but in the 1871-1872 edition, "When I Heard the Learn'd Astronomer" belongs to a group called "Songs of Parting" (source). We're not sure how to explain this editorial decision on Whitman's part, except that the speaker does "part," or walk away from, the crowd in the lecture hall.