If you're anthropomorphizing the heart (treating it as an imaginary person), either would probably work. English doesn't have a very strong convention in general for which gender things should be considered if they don't biologically have sexes. (There are exceptions, mostly for things like vehicles and countries, and most deities are person-like enough to be considered to have a gender whether or not they have any physical or metaphysical sex.)
Really, though, it's usually going to be best to just treat the heart as the object it is and use the impersonal pronoun "it". And in the particular context given in the question, there's nothing wrong with "it" and it's unlikely that either "he" or "she" would make any sense.