The power dissipated in a series voltage regulator such as the 7805 equals the differential voltage across the device times the current through it (plus a small amount of power used by the regulator itself). With 12 V in and 5 V out, the differential voltage is 7 V. At 40 mA out, that's a peak device power of 0.28 W. If the 40 mA is constant, then the average power also is 0.28 W. Go through the datasheets and add up the currents of everything that is powered all the time separate from the things that are powered intermittently. To the "all the time" list add in the regulator circuit power. As I recall, a 7805 has about 10 mA of current in the ground pin. This is coming directly from the input, so it adds 0.12 W to your list. With these numbers you can calculate the peak and average power dissipations.
OK, so what. In very round numbers, at 1/4 W in free air a TO-220 package will get warm but not hot. At 1 W it will be painfully hot and at 2 W -ish it will go into thermal shutdown or fail. This should give you a starting point for determining how to protect your circuit.
ak