Blood flows past the eardrum. It picks up the vibrations as sound and you hear this. This is quite normal for many. While during the day I am usually don’t notice the sound of my heartbeat in my ears, when I go to bed if I pay attention it is obvious.
My brother had this problem for a while, when he was around 15 or so. It started out of the blue, and it drove him nuts-- he had trouble concentrating on schoolwork and his grades dropped, he had to listen to the radio to fall asleep, etc. He went to a few doctors and they told him that there’s a natural insulation in the ears to block your heartbeat and other “body function” sounds. His blood pressure, cholesterol, salt, etc. were all normal, and they couldn’t really do anything for it.
AFAIK, it eventually went away by itself. I know that’s not helpful, but it’s not necessarily permanent anyway. I think they referred to it as a form of tinnitus (sp?) but I could be wrong.