Praise be to Allaah.
Fasting is not only a remedy, it is also a purification of the soul and a means of earning reward and the pleasure of Allaah. It is also a striving against one’s desires. With a little patience and the hope of earning reward, one can get used to fasting. Allaah says (interpretation of the meaning):
“Observing As-Sawm (the fasting) is prescribed for you as it was prescribed for those before you, that you may become Al-Muttaqoon (the pious)” [al-Baqarah 2:183]
In the Tafseer of this aayah it was said that according to one opinion, the phrase “that you may become al-muttaqoon” means: that you may stay away from sin, because fasting is more of a deterrent and is more effective in keeping one from falling into sin. This is one of the meanings of the hadeeth, “Let him fast for that will be a protection for him.” Many people think that this is because fasting weakens the body and thus weakens desire. Even if that is the case, it is in addition to the fact that fasting motivates a person to keep away from anything that he fears may affect him adversely, either because of the blessing of the fast itself or because if the one who is fasting has to refrain from food and drink that are permissible, it is even more appropriate that he should keep away from things which are forbidden.
Fataawa al-Subki, part 1: al-Siyaam: Hifz al-Siyaam ‘an Fawt al-Tamaam
When young people who are unable to marry were commanded to fast, this is a sign of the wisdom and insight of the Lawgiver. It is clear that fasting has an effect in this regard and that it helps to control desire and reduce provocation.
With regard to your question about taking medication that can reduce desire, there is no reason why you cannot take some herbal extracts etc. to control your desires, so long as they are not harmful in any way. But this will not be of much help if you do not do some acts of worship to fill your time and other activities to use up your physical energy, such as Da’wah activities and helping those in need. Also reduce your intake of rich foods, do some sports activities, keep yourself busy with useful things, and make yourself a schedule that will use up your excess physical energy. Do not forget that it is also very important to keep away from sources of provocation. Be optimistic and do not think that you will remain in this situation for many years. May Allaah make it easy for you to marry soon. May He protect us and you from evil and guide us to the Straight Path.