Why do I sometimes hear my heartbeat in my ears?

Heart sounds. Can't tell if you're hearing actual heart sounds or the swish of blood flow in the cranium adjacent to your ears. There could be different reasons for each of those.