Not necessarily: If you are not allowed to wear a mask for medical reasons, you can exempt yourself from the mask requirement. However, you will need a valid medical certificate or medical proof, which you must carry with you.
A good tip: If you cannot wear a mask for medical reasons, have your doctor issue you with a certificate or medical proof in good time before your flight.