
First of all, it may seem obvious, but of course you'll need an appropriate pair of headphones. Fortunately, in terms of quality and accuracy of sound, cans are cheaper than a corresponding pair of speakers - for the price of some pretty budget studio monitors you can get a very high quality pair of headphones.
When looking for headphones, it's important to think how you're going to work on them - are you going to write and lay out tracks, or will you also be wanting to mix down? Mixdowns will require a substantially better headphone, and will also want to be open-backed for a more natural sound. If you're just writing, you'll be able to get away with a cheaper, and perhaps more coloured pair. DJ headphones, for instance, often have big bass, a closed-in sound, and detail sacrificed in the name of impact that will punch through a club soundsystem. If you're writing a house track, they'll probably be a lot of fun to write with; but your mixdowns would soon become very difficult!
While we're on the subject of choosing headphones, you should also consider researching the frequency response. The following link allows you to compare graphs for different sets of cans (remember, a flatter line is better) and shows some interesting results. You can see for example that although Sennheiser HD25's are something of an industry standard for DJs, they have a big hole around 4kHz which may result in overcompensating with some very 'toppy' mixes.

When you come to the actual writing process, it's important to take into account the differences between headphones and speakers. Headphones offer you a very 'spacious' soundscape, where every detail can be heard, every reverb tail can be followed through to its conclusion, every delay can be panned and placed exactly. Which is great, but it can very easily lead you to over-do it on the effects; an intricate soundscape may be beautiful to listen to on the right cans, but when you play it on a club system, the detail can lead to a muddied and confusing mixdown. So, it's important to reference your tracks on other speakers as often as you can.
Another factor that is extremely important to bear in mind is to look after your ears! This is something you should be doing at all times, of course, but it's particularly easy to go mad when you've got the headphones on. You want to write a club banger, you crank up the volume to get the vibes flowing a bit more, and the next thing you know, you're battering your poor eardrums with pressure levels you'd never be able to get out of a pair of studio monitors.

This is bad for lots of reasons - first and foremost, you're damaging your ears. But on top of that, you'll be making it harder to judge what you're doing with the mix, since you'll desensitize yourself to certain frequencies (so take regular breaks), and you'll also bring the scary sounding Fletcher-Munson curves into effect. You can look these up if you like, but in layman's terms it means that different frequencies can dominate (or not) depending on what volume you're listening at. All the more reason to keep everything at a nice, balanced level. If you're going to be doing a lot of headphone writing, it may be worth getting a cheap decibel meter from an electronics shop and testing your listening levels to make sure you won't be doing any damage.
Last of all, we should talk hardware. Headphone choice is personal preference, but some of the most popular for writing and mixing down are AKG702, Sennheiser HD650, or Beyerdynamic DT990 - all of which will give you excellent results for the money. You'll need a good amplifier too - there's no point spending that kind of money on cans if you're just going to run them off the socket on your laptop (which will have to be cranked to power a big set like the AKGs). Finally, you'll need some sort of crossfeed box, which will feed a little bit of the right signal into the left channel, and vice-versa. This is because when you're listening on speakers, room reflections mean you'll still hear some of the right signal in your left ear - so a crossfeed unit will make things sound that bit more natural.
So, that's a brief summary of how to approach the writing process on headphones. It's not as scary as it might sound, and with some brief consideration you should be able to produce quality mixes as easily as you could with speakers. And your neighbours will love you for it!