I'm self-employed, and the work I do requires that I be online pretty much all the time. I definitely understand what the OP is talking about – the combination of the multitudes of distractions available online and a job that requires you to always be a single click away from those distractions can be tough. I've tried a ton of different strategies, but the ones I found that seem to work the best are:
1. Switch to a standing desk. I find that when I'm standing up, the fact that I will end up physically fatigued by farting around on the Internet tends to keep me focused. Combine this with
2. Workrave. It's a basic timer program (free), designed with ergonomics in mind, that lets you set time limits for work, micro-breaks, and longer rest breaks. What I do is set it up for 10 minutes of work followed by a 1 minute micro-break, and then a 10 minute rest break after 50 minutes of work. I stand up and work for 10 minutes, then the computer tells me to go walk around and stretch out for a minute, and I repeat that until 50 minutes have gone by; then I take my 10 minute rest break, check my email and whatnot, make a cup of coffee, etc. etc. and then get back to work.
If you don't have a lot of natural self-discipline (like me), it's really about consciously establishing a positive routine, rather than trying to punish yourself by locking your computer down or whatever. Worktime needs to be worktime, and Internet time/break time needs to have its own timeslot too. Just my $.02 – good luck! After being self-employed for 6 or 7 years, and struggling to maintain consistent self-discipline during that time, I understand how difficult it can be.