Capacitors can be used in conjunction with motors for:
starting capacitors (sometimes located in a case mounted on the motor)
surge caps (usually in terminal box)
partial discharge sensing caps (usually in terminal box)
switched power factor correction caps (usually in switchgear).
I'm guessing you're talking about small single phase motors and it is a starting cap.
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
Suggestion: The capacitors may also be linked to some filtering; however, the location on the motor top would not be so common. Usually, single phase motors have starting capacitors (and running capacitors, if applicable) mounted on the motor.