That's a great question - and an important one to consider in planning your workouts.
The answer is simple: You change your routine the minute it stops working - whether that's in 3 weeks or in 3 months.
I firmly believe that you can and should see noticeable, visible results on a weekly basis. When you stop seeing results, or the results slow down to a crawl, it's time for something different.
You don't necessarily have to change the entire routine, but some new stimulus must be put into the program or you're not likely to make any more progress.
Changing often is also a good idea for adherence because it helps prevent boredom and lack of motivation. New routines keep things interesting.
How often you should change is different for everyone - it depends on how long you've been training and what your goals are.
When you're a beginner, you can make progress on the same workout routine for a long time. Beginners should change every 3 months or so. The more advanced you get, the more quickly you'll adapt.
I've been training 20 years, and I seem to adapt to a training routine in as little as 3-4 weeks - sometimes in as little as 3 workouts! Since I work each muscle group once every 5 days, that's about 5-6 workouts in 4 weeks, so basically, I usually change my routines every month. If I'm on an off season strength program, I'll stay with the same exercises much longer, but I'll often change other training variables, so something changes approximately every 4 weeks.
Charles Poliquin, who is regarded as one of the top strength coaches in the world, says, "Any training program is only as good as the time it takes to adapt to it." Poliquin recommends changing every 6 workouts.
The problem with changing routines too often is that it fails to provide any continuity in your training. It's more efficient to "milk each routine for all its worth," THEN change than it is to change every workout at random.
That said, "muscle confusion" is certainly a valid technique for bodybuilding or pure cosmetic improvements. In other words, if you're training just to "look good, " changing routines every time you go to the gym is worth experimenting with.
For strength athletes, on the other hand, continuity on the basic exercises is extremely important. You can't build up maximal strength if you keep changing and dropping your core exercises out of your routine.
If you're training for strength, you can change training variables such as rest intervals, tempo, volume and repetition range on a weekly or monthly basis, but you should stay with the same basic core exercises (squats, presses, rows, deadlifts, etc) for a longer period of time. This allows time for maximum strength gains to accrue.
Training routines are covered in detail in my bookBurn the Fat, Feed the Muscle (BFFM)