Typically, the best time to move to a better opportunity will be when you are doing your best work at your current job. It gives you more leverage than when you are unemployed. Think of it as career momentum.
If you are happy with a job you have and it pays well, there is nothing wrong with staying as long as you like. Long stints in a position always stand out on a resume - it shows stability and reliability.
If things are "alright" or unhealthy, keep your ears to the ground, and stay open to conversations with trustworthy recruiters. Feel free to ask a recruiter any questions you have about the position or your career. Their answers might be self-interested, but often, they have a good pulse on the position and industry.
Finally, long answer short: I encourage anyone to spend at least 12 months in any position. Even if it is not for you, you will grow and mature in a tough position.