Caring for your bike's chain won't just prolong its life, it will mean your bike will ride as smoothly as it should too. Chain lubrication should be carried out roughly every 500km or so, so if you're a weekday commuter then simply make it part of your weekly maintenance schedule, while dirt bike riders should give it a once over each and every ride.
A well lubricated chain will ward off corrosion, run quieter and last longer, and it will prolong the life of your sprockets too, so it's well worth the effort. A variety of different brands of chain spray are available, but go for a wax-based type of spray – these tend to cling better, with more of the lubricant sticking to your chain, rather than all over your wheel and swingarm.
If you've got a road bike with a centrestand you'll find lubricating your chain takes seconds - simply put the bike on the centrestand on level ground, engage neutral and spin the wheel around while you spray a decent coating of lubricant onto your chain. If you don't have a centrestand, like if you've got a sportsbike, you can always buy a race stand that performs the same job - you'll need one to easily and effectively adjust your chain anyway, and they're a help in bike maintenance and cleaning in general, so whatever way you look at it it's a good investment. Similarly, dirt bike owners will need a dirt bike stand - these use a small amount of leverage to lift the bike up from under its engine.
And here's a tip - if the chain is warm to begin with, ie you've been riding the bike for a few minutes to get some heat into it, you'll find a lot more of the chain lube will actually work its way into the links and stay there, as opposed to flying off within seconds after you've ridden off with a cold chain.
A lubricated chain will pay dividends in the long term, but there's more to keeping your chain happy than simply keeping it well lubed - a thorough clean every now and then also helps and often highlights any minor problems before they become major ones, while maintaining the correct chain tension is vital.