Depends how much and how hard you ride. And how clean you keep everything. If the gears are slipping and you can't prevent it by minor adjustments like tightening the cables, then you know the cassette needs replacing. You can also get a tool to check the chain "stretch". (As the links wear the distance between them gets longer. You can check with a ruler too, which is a little less convenient but gets around buying another single purpose tool. Alternatively just get your bike serviced regularly and they'll tell you!
no subject