As you have a heart ailment, any exertion can put more load on the heart and cause symptoms
So mild to moderate exertion is ok
Mastrubation occasionally will not cause any problem.
If you develop any shortness of breath
or chest pain
, then you must stop.
Thanks and Regards