It's very, VERY inconsistent. The TOS/classic movie Enterprise was due to be retired after 20 years (STIII). Enterprise NX-01 after a mere ten (ENT: TATV).
Then we get ships like the Hathaway, which is still spaceworthy and being used for training exercises after 80 years. We saw a heavily damaged NX-01 last 100+ years in an alternate timeline in "E2"
The Klingon D7/K'tinga design has been used for at least 225 years (first appearance: ENT: "Unexpected" in 2151, seen throughout TOS, TNG and DS9) and the Bird of Prey for almost as long. Although I don't know how long each individual ship is supposed to last. Their rusty, worn out appearance suggests they're very old.