In this poem, Shelley talks about the west wind as both a creator and a destroyer. He says that as it destroys things (through storms) it is also recreating new landscapes and new life. He hopes that his poetry will be able to do the same for the human world. It is in that context that we can understand the last line.
What Shelley is saying in this line is something like the proverb that it is always darkest before the dawn. He is saying that when winter comes (in the darkest and bleakest time of the year) we should not be discouraged. This is because spring, the time of rebirth, will be coming soon. The same processes that destroy (the west wind, the passage of time) will also cause renewal.
Melancholy, which is a salient characteristics of Romantic Art, is a typical feature of Shelley's poetry. Ode to the West Wind is an impassioned call to the abiding reality of nature wherein he implores it to blaze away things which are dull and sick. He urges the Wild West Wind to Bring on the wind of change.
The poem is divided into 5 stanzas, and Shelley has finely distributed the roles on the West Wind in each of them. It has been sometimes shown as the destroyer and sometimes as the preserver. Shelley himself has been shown as somebody longing to share the brute force and the all-engulfing power of the West Wind.
The last line "If Winter comes, can Spring be far behind?" is the key to hope in this poem which is full and locked with ideas pertaining to negativity although well-intentioned. Without this line, Shelley would have been typecast as the "great-mourner" without a reason to mourn. [He was the grandson of a rich country squire and had never experienced abstract poverty as Keats.] The 70 lines of the poem can be classified as the build up to the last two lines. Shelley wanted to unleash the power of change and positivity onto the youths of his age, [He was only 27 when he wrote this poem] and he chose the West Wind to carry his message.
Autumnal decay and the barrenness of winter may make the world desolate, but beyond lies waiting the Spring of another year. It is this ebb and flow, the endless 'baffling change' of the great tide of humanity, which Shelley sings, as well as the death and exit of dreary regenerative seasons.
Shelley sings in exquisite melody of the advent of millennium. Possessed by the creative principle, his dead thoughts become ashes and sparks to feed a new conflagration. The poem ends on a note of hope and promise of triumph.