One trick is to stop working on what you're currently doing but leaving the obvious next step not done. Then when you're doing the other thing, you'll have that undone thing in the back of your mind to get back to. It also makes it so much easier to get started on the other thing because it's 'ready-to-go'.
Another trick is to incrementally setup up pieces in the other thing for what needs to be done next. No matter how big the task is, getting things ready to start a big task is a bunch of little things. You keep going back and forth between the thing that you're doing and setting up bits of the other thing. At some point, you'll realize that everything's ready to go and you're already doing it without realizing you've started.