You can break your fast if the pain or difficulty from it is unbearable, or if there is the potential for harm. You can do this at any time when it becomes unbearable. In such a case, you would just make up the fast after the month of Ramadhan. If you do not make it up before the next month of Ramadhan, then you must pay kaffarah based on obligatory precaution.