I spent five years working for Kensington, a company that made its reputation in the Mac world by selling fantastic mice and trackballs. During the time I worked there, we saw the computing world transition from opto-mechanical devices (in which a ball turns slotted rollers connected to wheels whose speed and direction were measured with photosensors) to purely optical devices (in which a tiny camera tracks changes in the texture of your desk's surface, or the trackball's surface).
The biggest and most exciting advantage of optical designs was supposed to be that they never had to be cleaned. Gone were the old days of disassembling a mouse, losing the ball as it rolls across your office floor, and fumbling with cotton swabs to clean dirt and hair off of tiny rollersa procedure you might have to repeat every few weeks or so. Optical mice have no moving partsno rollers, no ballso cleaning should never be necessary.
Experience has shown that although optical devices require less cleaning, they still require some. Specifically, optical mice tend to accumulate dust inside the opening at the bottom (often shaped like a keyhole) through which the sensor watches your desktop. If it becomes clogged, your pointer may move erratically, or not at all.
Optical trackballs have a similar opening above the lens (remove the trackball from the casing to see it) with a similar tendency to attract dust. In addition, the tiny bearings or rollers on which the ball rests can collect dust and hair, preventing the ball from moving smoothly.
And, of course, plenty of Mac users still have older pointing devices that use the ball-and-roller mechanisms and therefore require what we now think of as old-fashioned cleaning.
Your input device most likely came with cleaning instructions, so I'll simply say: follow them now. If you don't have the instructions (and can't find them on the manufacturer's Web site), they generally boil down to removing visible dust and gunk from wheels, rollers, bearings, and other moving parts (and away from the openings used by optical sensors). A slightly moistened cotton swab will do the job nicely.
Cleaning Mighty Mouse's Scroll Ball. The miniature trackball that enables you to scroll with an Apple Mighty Mouse can accumulate dirt, leading to poor scrolling performance. You can't remove the ball, but you can generally dislodge any dirt by inverting the mouse, pressing the ball inward as far as it will go (it springs inward slightly), and rolling it vigorously in every direction. If scrolling is still not smooth after you do this, repeat the procedure using a slightly moistened cloth or paper towel.
For most people, once a month is a reasonable cleaning interval. If you have pets, you may need to clean your mouse or trackball more frequently; if you work in an Intel clean room, maybe never!