If your happy; learning new things, getting a consistent raise, like the work, get along with others there and find the work challenging - stay.
If not, for various reasons - don't like the benefits; think you could earn more money elsewhere, learn new things elsewhere - start looking.
Programmers need to take emotion out of their jobs. It's a job. If your skills are stagnating; if your miserable; if your not making what you feel you should be making - you should look elsewhere. Most (all?) employees owe their company nothing. Regarding a normal every day, day job, we're not doing charity work. You get paid a fee to produce x. So if your happy with everything - stay. If not - time to move on. The date on the calendar isn't important. Your career and supporting yourself / family, progressing your career is important.
(edit - missed the 2nd part) - I was at a job for 8 years. I learned a lot at the job and continued to do so until I was let go (cut backs) but the pay was sub par. We are made up of our experiences and getting let go gave me the confidence (needed a new job) to find something better. Since then I've had 2 jobs, 1 for 8 months which I left because I didn't like the work and the second (current job) which I love and have been at for 2 years now. My current work is a bit boring (only downside of the job) but the pay is great; everyone is nice and "easy" to work with and the benefits outweigh anything else I've come across.