Fasting and Praying without Ghusl after Masturbation
Question

I hope that you can advise me about my situation. I have researched a great deal but I have not found any answer and I am living in a state of constant anxiety. I hope that you can advise me.

When I was young, I did the secret habit (masturbation) from the age of 12 and I did not know what it meant or even what it was. At the age of 14 I found out that it was that bad secret habit, but I did not know the ruling on it; I only knew that it was serious and that it causes diseases. At that age I did not pray, but I used to fast without praying.
At the age of 15, I began to pray and fast and I stopped listening to music, but I still did the secret habit and did not know the ruling on it; if I did it, I did not do Ghusl and I used to pray and fast after that. I did it twice during the day in Ramadan, I am not sure.
At the age of 18, I read in a book that it is prohibited and that Ghusl is required after it, but I could not repent from it and I carried on doing it even after getting married. But now I have repented sincerely to Allah and I am 27 years old. 
My question is: what is the ruling on what I did and what should I do? 
What is the ruling on my fasting and prayers when I used to do it and did not do Ghusl, then I would pray? What is the ruling on my fast and what is the expiation for what I did? What is the ruling on the two days on which I did this habit in the day in Ramadan and what is the expiation?
Praise be to Allah.Is masturbation prohibited in Islam?
Masturbation, or what is called the secret habit, is prohibited because of the evidence which has been explained in the answer to question number 329 . If climax is reached as a result, it is obligatory to do Ghusl (ritual bathing). 
There is no particular expiation for masturbation , but it is obligatory to repent from it, by giving it up, regretting having done it and resolving not to go back to it. 
Does masturbation break the fast?
If doing the secret habit is accompanied by climax, then this invalidates the fast and prayer is not valid unless you do Ghusl. 
If it was not accompanied by climax, then your prayer and fasting are valid. 
Masturbating while not knowing that it breaks the fast
If a person masturbates and is ignorant of the ruling that it is obligatory to do Ghusl afterwards and that it invalidates the fast, does he have to make up the prayer and the fast? There is a difference of opinion among the scholars concerning that, but the majority are of the view that it is obligatory to make them up . Some scholars are of the view that it is not obligatory. 
In order to be on the safe side, you should make up the fast of those two days, if climax was reached. 
With regard to prayer, you should offer a lot of Sunnah prayers and righteous deeds, but we do not think that you are obliged to make them up. 
Signs of reaching puberty 
You should know that there are signs of reaching puberty and that a girl may reach puberty before the age of 15, if she starts to menstruate or if any of the other signs of puberty appear. For more information on that, please see the answer to question number 20475  and 21246 . 
What happened to you emphasises the importance of seeking Islamic knowledge, which is something that is easy to do nowadays, praise be to Allah. 
We ask Allah to guide us and you and make us steadfast. 
And Allah knows best.