When is a good time to rebuild indexes?

Are there any particular stats, queries that can be run to tell when an index is fragmented?