While some molds are used to make cheeses like Roquefort, Gorgonzola and Brie, there are kinds of molds that are not safe to eat because they can contain harmful bacteria such as listeria, brucella, salmonella and E. coli.
The rule of thumb is to discard soft cheeses, such as cottage cheese and cream cheese, that have developed molds in them. Since these cheeses are soft, the mold's thread-like roots can easily burrow deep into the cheese and contaminate it with harmful microorganisms. Moldy shredded, crumbled or sliced cheese should also should be tossed into the trash bin.
For semisoft cheeses, such as Cheddar, Colby and Swiss, you can just cut away the moldy part and eat the rest of the cheese. To be safe, cut off at least one inch around and below the moldy spot. Be sure to keep the knife out of the mold itself so that it doesn't contaminate other parts of the cheese.