A strong core and strong upper body are necessary to keep you upside down in any inversion. Though you will gain both of these through an inversion practice, it is important to note that you need to take things slow to get there. The more you control your movements, the greater the strength you will develop. (So don't throw your legs up there! Not only will you have a harder time gaining balance from the momentum, you lose the chance to really develop your core.)
Before you jump right into this guide to headstands, be sure to warm up the muscles that are crucial to support your body in a headstand through:
Sun Salutations, and/or core exercises/poses, downward facing dog, and stretching to loosen up your hamstrings.