A key sign to watch for when you buy Parmesan is noticing mold spots on the cheese. This can be gray or green, and it will ruin your dinner. The good news is that mold cannot penetrate hard cheeses like Parmesan, so you can cut the nasty chunks off and continue to use them. You may even be able to eat the moldy pieces, but you should throw them out.
You can usually tell if the Parmesan is wrong if it develops a funny smell or has mold spots.