First you should ask your doctor about it, because it’s possible there’s some kind of medication (s)he could offer you to help with this. I know that a lot of people think ADD and ADHD are sort of hokum diagnoses that are overused and overmedicated these days, but I’ve seen firsthand that some folks really do calm down and get a lot more functional when they have access to those medications.
Beyond that – I also have this issue sometimes, and I find it helps to get rid of anything I’m finding distracting at that particular time. Usually that’s just my phone (I put it out of reach so I won’t be tempted to compulsively grab it and check it all the time) but sometimes it’s my whole environment (family members, cat, my room that needs cleaning, colorful pictures on my walls, etc.) so I have to remove myself from that environment and go somewhere else if I want to get any work done. Coffee shops and libraries are a godsend for this!
I know that there are also productivity apps you can install on your computer that prevent you from accessing any websites/programs other than the ones you actually need to use for the task at hand, so you might take a look at those. Personally I don’t use them because, in my work, I quite often need to go on Google or even refer to social media sites, etc. as research for things I’m writing, so it wouldn’t be effective for me to bar myself from those – but some people love ‘em.
I also know that FOR ME, caffeine can be a really good focuser. A big latte gives me the mental energy to work with dedication on one task for at least an hour. For some people, it can make them even more scattered and distractible. Might be worth experimenting with, if you haven’t already and if it isn’t contraindicated with any medications you might be on or medical conditions you might have, but as I said, it works differently for everyone.
If I’m studying/working with a friend, sometimes I can get them to bribe me with some kind of treat if I work for a certain number of minutes without interruption. This isn’t foolproof because it’s pretty easy to sneak a peek at Facebook or whatever without your friend noticing, especially if they’re working on their own stuff. But for me, it can be effective because I get embarrassed about even the THOUGHT of my friend glancing over and seeing me slacking. (You could also just reward yourSELF for completing a certain number of minutes of work, but I find self-reward systems can be a slippery slope toward total laziness and abandoning the task.)
Aside from that, I think it’s a good idea to continually look for any and all triggers that help you get into a productive headspace. I like soft instrumental jazz or classical music, coffee shop sounds (from a real café or from coffitivity.com), comfortable cozy clothes, having a carefully organized to-do list next to me at all times, and having as few browser tabs open as possible. It can take some work and trial and error to figure out what works for you but it’s so worth it!
Good luck! xox