It's a metaphor to emphasize the difference between the movable heads of flowers and their static leaves and stems.
First, note how the poem is at pains to point out that the leaves stay still:
The rambler vine climbed up the cottage post,
the leaves in the night still where the day had placed
"still where the day had placed them" here meaning the leaves remain in position at night.
The flowers of many plants, by contrast, do not stay still but turn to face the sun, a phenomenon known as heliotropism - the word derives from the Greek for "sun turn" - or phototropism.
the animal heads of the flowers where they had
to think at the sun
The flowers thus have "animal heads" because the heads can move like an animal can, in contrast to the still, passive nature of the rest of the plant. They have "arisen" because they are upright, having tracked the sun in the sky above. To "think" at the sun reinforces the animal metaphor because, again, plants do not think whereas animals enjoy basking in it - including humans, who often find such time mentally stimulating.
It is worth noting that a general theme of this poem is the hopefulness of youth: the open-mindedness to new experience and the expectation of good things to come. In this light, the metaphor for flowers opening and moving in response to the sun is a strong one. The sun is often seen as a symbol of renewed hope, as is the opening of new flowers in the spring after the long darkness of winter. Spring and the dawn, in turn, are both metaphors for youth. By emphasising their "animal" nature, the poet is tying the botanical flowers closer to his own animal status.
- Ginsberg, Allen. "Notes Written on Finally Recording 'Howl.'" Deliberate Prose: Selected Essays 1952-1995. Ed. Bill Morgan. NY: Harper Collins, 2000