Try assigning yourself a specific place to sit (e.g. by a desk) that will only be used to take care of homework and other school-related things. If you sit by your computer or recline in your bed, you'll most likely end up surfing the Internet or falling asleep, respectively, as your brain has been trained through repetition to associate those locations with their related activities.
"Stephen Wolfram is the creator of Mathematica and is widely regarded as the most important innovator in scientific and technical computing today." - Stephen Wolfram