The equation for this relationship is: 
This is a particularly important law when discussing heat engines (like car engines), because it helps to understand that heat must go somewhere—the basis for cogeneration. As an engine creates heat, if the heat is not vented, the engine will become hotter and hotter, which will eventually lead to melting. Therefore, because it is impossible to achieve 100% efficiency (see carnot efficiency), heat must be vented. This can either be treated as waste heat, or used for cogeneration, which is applying the waste heat to another cause, like heating a car, or heating houses.
To learn more about the first law of thermodynamics, please check out hyperphysics.