The brain communicates with the heart via the autonomic nervous system's parasympathetic and sympathetic branches.
The sympathetic and parasympathetic branches of the autonomic nervous system control the heart directly via multi-synaptic pathways from myocardial cells to peripheral ganglionic neurons and then to central preganglionic and premotor neurons.