In this section of preaching, Jesus 1) assumes we will fast 2) warns that the command means some will misunderstand it and do it for self-righteousness-feeding attention and 3) makes clear we should not fall into that temptation, but fast out of a heart that longs for God, keeping that longing expressed through fasting privately, which, in this way, will guarantee a reward (!) from our Father.
“And when you fast, do not look gloomy like the hypocrites, for they disfigure their faces that their fasting may be seen by others. Truly, I say to you, they have received their reward.
But when you fast, anoint your head and wash your face, that your fasting may not be seen by others but by your Father who is in secret. And your Father who sees in secret will reward you." (Matthew 6:16-18, English Standard Version)