For my team I typically start a refactoring sprint roughly once every three to four months. Considering we run 2-week sprints, that's one refactoring sprint roughly every seven sprints.
I run the refactoring sprint like any other sprint - strictly 2 weeks time limit. Sometimes we even run just 1 week refactoring sprints (when something urgent comes along).
A note on refactoring sprints: don't be too ambitious:
- Realize that refactoring is an infinite cycle: you'll always find a better way to do things.
- It's OK if you refactor only 10% of what needs to be refactored.
- Treat refactoring like any other stories so that you are forced to prioritize what to refactor and recognize where in your code is in most need of refactoring. The only difference is that for refactoring stories I let developers set priorities.
- A partial refactor will still leave your code in a better state than no refactor at all. Plus, it tends to make further refactoring easier.
- Refactoring happens even outside of refactoring sprints when working on stories, but only if the refactoring is a low-hanging-fruit that doesn't interfere with stories being completed.
This is what I personally use as a guide to refactoring. It not only make refactoring managable but also serves as a good indicator for when you're overdoing it.