There're many techniques that can help stay focused on task. You got some good tips already. What I want to suggest is you need to start with the problem: what is it that distracts you? Phone? E-mail? Friends? Music? TV? Once you zoom in on the distracting factor, see if you can remove or, at least, reduce it.
You may discover that it is not some external factor that distracts you. Your own mind simply starts drifting away after awhile. If this is the case, it's OK. Anna is right, it is normal for people to get distracted. Switching activities can help restore the focus. When you feel that your can no longer focus on your task, take a short, 1-2 minute, break. Stand up, stretch, do some jumping jacks, pullups, pushups, crunches... Any physical activity is a great way to re-set your brain.
Here's a little bit of a background information for you about the workings of our brain. For learning to occur, brain needs to have the right balance of chemicals: dopamine for a feeling of reward, and norepinephrine for alertness. This balance is achieved when we pay attention. So when you start getting distracted, the balance between these two chemicals is getting distorted. Typically, the level of dopamine starts going down. To restore the balance and raise the level of dopamine, brain needs novelty. Which can be achieved by either switching to a different activity or to a different learning method. For example, if you were reading a textbook, put it aside and write down some notes. Or do some online research to find additional information on the subject. Or try to retell what you just read... Do it for a few minutes, then go back to your original method of study.