This was an extreme problem for me. I started a Shakespeare paper at three in the morning and the class was at eight. I found that going on walks helped clear the war in my head. Also music on headphones was instrumental. I would play one album over and over and it helped me get some focus. My desk setup at home was such that I was visually blocked from external distractions. If you are new to writing papers then it gets better when you have a few under your belt.