Lubricate the chain every 1,000 kilometers or less if you ride in the rain. Every other time you do it, clean the chain first using a soft toothbrush and paraffin or commercial chain cleaner to get rid of all the accumulated hidden dirt.
Just after you've ridden the motorcycle the chain will be warm or even hot. That's the perfect time to lube it. The heat means the lubricant will penetrate deeper into the rollers and spread into all the nooks and crannies.
Most manufacturers say avoid aerosol lubricants and just brush on heavy oil. Heavy oil will make the chain last well but it flings off, can get on your tyre and needs reapplying too often. Use two types of chain lubrication – first a thin, runny one to penetrate and lubricate. Next use a thick one or chain wax to coat the outside of the chain and prevent rust.
Ideally get the back end off the ground with a paddock stand or the motorcycle's center stand, Put some newspaper under the motorcycle to catch any overspray. Now turn the wheel by hand – use the engine and you risk getting a finger trapped which will involve some hospital visits.