Mold on soft cheeses, such as cottage cheese, cream cheese, and ricotta cheese should be discarded. The same is true for any kind of cheese that shreds, crumbles, or slices. With these cheeses, the mold can send filaments throughout the cheese. In addition, harmful bacteria, such as listeria, brucella, salmonella, and E. coli, can grow along with the mold.
Mold generally can't penetrate far into hard and semisoft cheeses, such as cheddar, Colby, Parmesan, and Swiss. So you can cut away the moldy part and eat the rest of the cheese. Cut off at least 1 inch (2.5 centimeters) around and below the moldy spot. Be sure to keep the knife out of the mold so it doesn't contaminate other parts of the cheese.
Not all molds pose a risk. In fact, some types of mold are used to make cheeses, such as Brie and Camembert. These molds are safe to eat.
If you're not sure what type of cheese you have or what to do if it grows mold, the safe course is to discard it.
Resource
If a piece of cheese has mold growing on it, should I throw the cheese away? Mayo Clinic Katherine Zeratsky, #RDN