The Mayo Clinic website clarifies that soft cheeses, like cream cheese and ricotta, which may contain mold, should be avoided. The same applies to any types of cheese that have been crumbled or sliced. Generally, mold cannot penetrate hard or semi-hard cheeses. Therefore, you can simply cut away the moldy part. Make sure to clean the knife from any mold to prevent contamination of the remaining cheese.
Of course, not all types of mold are dangerous. Some molds are used in cheese-making, such as Brie and Camembert, and are generally safe for adults to consume. However, individuals with weakened immune systems, the elderly, pregnant women, infants, and young children are advised to avoid these cheeses, as well as soft cheeses made from unpasteurized milk.
The Egyptian Ministry of Health and Population has also warned against consuming moldy cheese through their official Instagram account. They stated that "mold secretes toxins onto food substances, thus posing a risk to health and potentially leading to cancer."