I had problems focusing at my last job, which ultimately got me fired because it affected my work negatively. Now that I am in a new place with new people I just dive right into the work and nothing else, I don't really talk to anybody and I use my job to escape from everything else because I think of nothing but doing a good job. Sometimes my mind will wander but then I mentally slap myself back into the now and concentrate on what I am doing in the present moment.
Look up cognitive behavioral therapy and mindfulness......
http://www.excelatlife.com/ <--- this is a great site and if you have an android phone you can download CBT diary and some other helpful apps that they have....
the articles are good reads as well...