One very easy way to calculate which size heater you need is to times your aquarium's water capacity by 5.
For example if you have a 20 gallon tank: 20 x 5 = 100. So you need a 100w heater.
However, sometimes you will need to add in factors such the room temperature in which your aquarium is to be located. This is especially true if your tank is located in a cold room and you intend to keep tropical fish. I would then simply choose the next size heater up which in my example would invariably mean opting for a 150w heater.
Another option that many fish keepers recommend is to have 1 heater on each side of the tank.. The benefit of this method is that your water temperature remains much the same at either end of the aquarium without having any cold spots. In my example you would then have a 50w heater at each end of the tank. This also ensures that if one of the heaters failed you would at least have the other heater as a back up source of heat until you are able to replace the faulty heater. Bare in mind though that you may need to turn up your remaining heater to help maintain your desired temperature.