Fasting (siyyaam or sawm) is an act of worship which involves abstaining from all food, drink, sexual activity and anything which is bound to break the fast from dawn (the time of calling to the Fajr prayer) till sunset (the time of calling to the Maghrib prayer).
First thing to know is that fasting is of two types: obligatory and voluntary. Obligatory fasts are required worship. Voluntary fasts are optional - one may keep them or not. You won’t incur any sin, but will get extra reward for keeping them. Muslims are required to observe a strict month-long fast once a year, that is, during the month of Ramazaan. There are also recommended fast, as long as one are able to do so, to fast on other days in order to gain more rewards. 
The first thing to understand is the difference between what is known as fard and what is known as nafl. Fard is obligatory, it is what Allah requires us to do, and leaving it is a sin and we will be held accountable for it. An example is two rakah of Fajr prayer and the fasts of Ramazaan.
Nafl literally means extra. Nafl worship is voluntary, it is not required from a Muslim, rather it is up to the individual to offer it. It is optional and voluntary. The Muslim is not sinful for neglecting nafl, but is rewarded for doing it. Therefore, nafl worship is recommended. Examples of nafl fasts are given below.
Voluntary fasts provide an excellent opportunity to practice fasting while earning rewards before Ramazaan approaches. At the same time, one must remember not to burn out, but to be gradual without being negligent.
The Prophetﷺsaid, “Whoever fasts during the month of Ramazaan and then follows it with six days of Shawwal will be (rewarded) as if he had fasted the entire year.” Sahih Muslim: 1164
It is forbidden to fast on the day of Eid or Eid-ul-Fitr to be specific. You can keep these six fasts anytime after the day of Eid and they do not have to be kept consecutively. If you wish you can fast them separately as long as they are completed within the month of Shawwal.
The Islamic month in which the Hajj is performed is known as Dhul-Hijjah. “Day of Arafah” is the ninth day of that month.
It is recommended for those not performing the Hajj pilgrimage to fast this day as the Messenger of Allahﷺsaid: “Fasting on the day of Arafah is an expiation for two years, the year preceding it and the year following it.” Sahih Muslim: 1162
Muharram is the first month of the Islamic lunar calendar. The tenth day of this month has a special name – “Ashura.” What does one get for fasting it? The Prophet informed us, “Fasting the day of Ashura is an expiation for the past year.” Sahih Muslim: 1162
Abu Hurairah(R), the close companion of Prophet Muhammadﷺ, reported that the Prophet would fast on Mondays and Thursdays. When asked about that, the Prophet, may the mercy and blessings of Allah be upon him, said: “The actions are presented on every Monday and Thursday. Allah forgives every Muslim or every believer, except for those who are boycotting each other. He says (about them): ‘Leave them.’” Sahih Muslim 2565
When the Prophetﷺwas asked about fasting on Mondays, he said: “That is the day on which I was born and the day on which I received revelation.” Sahih Muslim 1162
‘Aisha, the wife of the Prophetﷺ, said: “I never saw the Messenger of Allah fast a complete month except for Ramazaan, and I have never seen him fast more in a month than he did in Sha’ban.” Sahih al-Bukhari 1969 and Sahih Muslim 1156
It was narrated that Abu Dharr said:"The Messenger of Allahﷺcommanded us to fast the three days of Al-Bid, the thirteenth, fourteenth and fifteenth (13th, 14th and 15th)." Classed as Hasan in Sunan an-Nasa'i 2422 and Jami` at-Tirmidhi 761 and Ibn Hibban 3647 and 3648
1. The intention for a voluntary fast can be made during the day
Let us say that you woke up and prayed Fajr. You did not have the intention to fast that day and you also did not eat, drink, have intercourse, or otherwise do anything that would break a person’s fast.
Later in the day, you can make the intention for a voluntary fast if you have not done any of those things that break the fast. This is based on ‘Aishah’s hadith: “The Prophetﷺcame to us one day and said: ‘Do you have any (food)?’ We said, ‘No.’ He said: ‘Therefore, I am fasting.” Sahih Muslim 1154, Sunan Abi Dawud 2455 and Sunan an-Nasa'i 2325But you must have the intention the night before to fast the next day for Ramazaan fasts.
2. It is permissible for one who is performing a voluntary fast to break his fast
The Prophetﷺsaid: “The one who is fasting voluntarily is in charge of himself. If you wish you may fast and if you wish you may break your fast.” Sahih al-Bukhari 1943
Abu Sa’id al-Khudri said: “I prepared food for the Prophet. He came to me with some of his companions. When the food was laid out, one of the men said: ‘I am fasting.’ The Messenger of Allah said: ‘Your brother has invited you and incurred expenses in your behalf.’ Then he asked him, ‘Break your fast and fast another day in its place if you wish.’ Baihaqi 8622