When I feel the urge to distract myself I'll just get up and do some kind of light bodyweight exercises that require coordination and balance, and then I'm ready to continue the work I was starting to dread.
If anyone reading is into launching maker stuff: consider putting some hardware/software pair on crowdfunding where the hardware connects to a workout detector (kettle bell with accelerometer, treadmill, DDR mat, whatever, my personal favorite would be a comically big crank on a resistance unit, even just a smartwatch with an accelerometer would do) and the software hooks into the computer's power management, detecting heavy load and enforcing some extra throttling unless the workout detector is worked. I believe that this could fool our motivation/reward system quite nicely.
As always, experiment and adjust
When I do pause, I can stop and do a few pushups. It helps me focus a bit better, and there's no context loss because I'm not doing or thinking about anything new. It's not much different from leaning back in my chair to think for a minute.
If I haven't slept all night, context switches are total killers.
If the problem requires me to keep in mind a ton of factors and dependencies while I develop (design or code), context switches can be quite bad.
If the distraction require me to drag up a ton of context from a couple of weeks ago, then it can be quite bad.
If I'm well rested and someone comes with a technical question that's hard but limited in scope, it's mostly fine and I can get back to it within a minute if not less.
Now I'm a little older and have a brief pause where I think back to where I was, but it's still pretty quick.