If the cooked lasagna smells “off”, then pitch it. Feed it to the dog if you simply can’t abide the total waste. Dogs’ stomachs can handle a lot worse food than we can, and “slightly off” lasagna isn’t going to hurt a dog. (He’ll love you even more, in fact.)
“When in doubt, throw it out,” is one of the few dicta that I do live by. I’d rather waste the time and expense of throwing out “iffy” food (and I am cheap to a legendary degree) than spend (potentially) days recovering from the self-inflicted agony of food poisoning. Been there; done that; ruined the T-shirt, the rug and the sheets in the process.
If I see shredded cheese with mold starting in it, then I pitch the lot. Same reasoning as above. If I can see it, then there’s more started that I can’t see. Brick cheese, as noted above, I just scrape off the visible mold and continue to use. (And place in a new container.) The advice from @Espiritus_Corvus is interesting; I’ll have to remember that for next time.
That’s one reason I very seldom use store-bought shredded cheese. I use brick cheese for most everything except pizza, and use the manual shredder liberally.
EDIT / ADDENDUM: Apparently, the Mayo Clinic agrees with me on the advisability of tossing the cheese.