It means that the heart was beating very fast.
You can say that something is racing when it is moving or going very fast.
Other examples:
- He raced down the street (= he ran/went very fast down the street)
- The car raced by the spectators (= the car went very fast by the spectators)
Of course, a heart doesn't move, but it has a movement -- it beats! That's what the sentence means.