Set aside certain hours that are going to be working hours. Wake up at the same time, start at the same time, eat at the same time, finish at the same time, etc. If you have the space, I've found it helpful to set aside a space, however small, specifically for working. I never work on the couch, for instance; I always sit at my desk. Try to find a routine that works for you and stick to it as best as possible each day. It's very easy to slip because no one is there to tell you not to except yourself.
Sometimes a change of scenery is nice, so you can go someplace else. Many people like coffee shops, though I'd rather go to the park and sit at a picnic table. Coffee shops are too noisy and the wifi is usually nearly useless. Better to just go sit in a park, tether up, and enjoy the sunshine and peace.
Equally as important as routine is self control. It's very easy to say "I'll just fix one more bug," and suddenly it's 9pm and you've been working for 13 hours. Sometimes things happen, stuff breaks and you need to roll with that, but on normal days learn to prioritize what needs to be fixed now vs. what can wait until tomorrow. And when you log out, be done for the day. Go and enjoy life and resist that temptation to log in later that night and fix "one more thing." :)
Take breaks. Take a walk around the block. Go out to grab a sandwich. Again, it's easy to get sucked in when you don't have normal workplace distractions. But sometimes those distractions are useful. Yeah, it sucks when someone interrupts you at your desk, but how often do you then decide it's a good time for a bathroom break, or to grab a soda or snack or something? Make those things happen at home. I find a variation on pomodoro to be a benefit here.
After work, go do something else. If possible, go out, even if it's just to the store. Get outside and get some fresh air.
Do you have family? If you do here are a couple of additional points:
Be sure you don't neglect your family duties. This seems counter-intuitive (because you're at home, right!) but I've seen several friends relationships suffer after they started working from home (and it's usually related to the self-control issues above - they can't stop when it's time to switch into family mode). Be sure your family is on board with you working from home and know what to expect.
But on the other hand, if your family is at home while you are home, be sure they realize that you are working and that they should _try_ not to disturb you and give you space to work. I work with a wife and 3 year old in the house and, while distractions do happen, they're both pretty good about allowing me space and quiet to get things done. I have the fortune of having a separate space to work and, while my door is usually open for them to come and go, they know that if I've closed the door that means I'm trying to focus on something and to try not to disturb me.
Oh yeah. And keep up with your personal hygiene. There is a level of truth to this Oatmeal comic . :)