Please contribute generously in order to ensure the continuity of our website InshaAllah.
Praise be to Allah.
Firstly:
Masturbation is haraam; we have previously discussed the ruling on it and how to deal with that in the answer to question 329.
Secondly:
The expiation for breaking an oath is explained in the verse in which Allah, may He be exalted, says (interpretation of the meaning):
“Allah will not punish you for what is uninentional in your oaths, but He will punish you for your deliberate oaths; for its expiation (a deliberate oath) feed ten Masakin (poor persons), on a scale of the average of that with which you feed your own families; or clothe them; or manumit a slave. But whosoever cannot afford (that), then he should fast for three days. That is the expiation for the oaths when you have sworn. And protect your oaths (i.e. do not swear much). Thus Allah make clear to you His Ayat (proofs, evidences, verses, lessons, signs, revelations, etc.) that you may be grateful”
[al-Maa’idah 5:89].
So the individual has the choice between three things: feeding ten poor persons or clothing them or freeing a slave. If he cannot do any of these things, then he moves to the option of fasting, so he should fast three days.
Thirdly:
If a person is unable to do any of these three things, so he fasts three days instead, then after that he has enough money to do one of these three acts of expiation, his fasting is still sufficient and he does not have to resort to any of these options. This is the view of the majority of scholars. So if he had started the fast then things became easier for him and he could afford to feed poor people after he had started the fast, he does not need to go back to the option of feeding poor persons, so this is even more appropriate in the case of one who fasted and has finished the fasts. Ibn Qudaamah said: If he has started to fast, then he becomes able to free a slave or feed or clothe poor persons, he does not have to go back to those options. That was narrated from al-Hasan and Qataadah, and it was the view of Maalik, ash-Shaafa‘i, Ishaaq, Abu Thawr and Ibn al-Mundhir. … Because it is an alternative and it is not invalidated by becoming able to do the action to which it was an alternative. So he does not have to go back to the first option after starting it. Similarly, if a person who is doing Hajj tamattu‘ and cannot afford a sacrificial animal has started to fast the seven days, he cannot change his mind about that, and there is no scholarly difference of opinion concerning that.
End quote from al-Mughni by Ibn Qudaamah, 10/22
Based on that, your fast is sufficient as expiation and cancels out the oath. Then if you repeat the act of masturbation which you have sworn not to do, you do not have to offer expiation unless you had renewed the oath and uttered it, then broken it.
And Allah knows best.