It's not in the 10 Commandments, but it's inferred through its usage that it's a good thing to do and a time-honored practice mentioned in the Bible many times:
“Even now,” declares the LORD, “return to me with all your heart, with fasting and weeping and mourning.” Joel 2:12
"So after they had fasted and prayed, they placed their hands on them and sent them off."
Acts 13:3-4
"There, by the Ahava Canal, I proclaimed a fast, so that we might humble ourselves before our God and ask him for a safe journey for us and our children, with all our possessions."
Ezra 18:21
Matthew 6: 16 “When you fast, do not look somber as the hypocrites do, for they disfigure their faces to show others they are fasting. Truly I tell you, they have received their reward in full.
17 But when you fast, put oil on your head and wash your face,
18 so that it will not be obvious to others that you are fasting, but only to your Father, who is unseen; and your Father, who sees what is done in secret, will reward you.