Really depends on what you are doing. Personally? I upgrade mine continuously. Whenever new toys come out I want, I gets. Videocards I do the most, but I tend to do a new core (motherboard, CPU, RAM) every 3 years. But that's because I a geek and love having high end computer toys.
For a general user that doesn't really want to think about it and decide based on performance or whatnot I just say "5 years." Get a computer with a 5 year warranty, and replace it when the warranty expires. You may not need one that often, but it means there shouldn't be any issues (since if there's a break it gets fixed under warranty) and makes planning simple.