Changes in heart rate is depends on the energy demand of the body. When you exercise, the energy demand will increase. Since the body needs more oxygen to make energy, the heart rate will increase to fulfill the demand. If you rest, the demand for energy will be decreased, thus the heart rate will be decreased too.