A good way to stay on task is to set a task list. For instance, if you are working on two simultaneous projects (generally a bad idea unless one is a brand new project), splitting your day into two parts is the best way to go. The first half of the day (before lunch) is spent on the priority project and the second half of the day is spent on the lower priority project. There is a two-fold reason for this:
1) People are better able to think in the morning regardless if they think they don't. Well, more real work tends to get done in the morning. After lunch, the food settles and drowsiness settles in for the rest of the day. I know people who take a late lunch for this very reason.
2) You want to look professional by doing higher priority items first. It makes you seem like you have it together. Most people really have no clue what they are doing. I tend to do the odds-and-ends tasks that build up to the main high-priority item. When people review my work they wonder where I am going with it. Of course, when it comes together within hours and it gets done, it has a fairly startling effect. At least people are impressed for the moment. Taking this approach makes you look like you only have moments of sheer brilliance and the rest of the time you are putzing around. If you aren't running the business, the approach doesn't make you good "promotional material" and the approach only works if you can squirrel away exactly how the code will look on screen in your head. Most people can't determine how code will look until it actually gets written. I'm one of the oddballs in the world that can get away with writing thousands of lines of code and not compile it once and have it work right the first time.
Anyway, I'm not exactly on task right now, so back to the grindstone...