I have a couple recipes that call for frozen or canned corn. If I want to use fresh corn instead, should it be cooked first or will it cook with the rest of the ingredients (like a casserole for example)?
Good question! Corn is very versatile. I've found that fresh and frozen whole kernel corn are very interchangeable when used in casseroles. Most casseroles cook long enough that you could use either without making any adjustments.
However, canned corn is a different animal. Because it is more processed I would use it in recipes that call for it but I would not consider it a substitute for fresh or frozen.
You want to cook fresh corn as quickly as possible.
Picking corn will start the process by which the sugars in the corn will convert to starches. Although american sweet corn has been bred for additional sugar so it will still be sweet for a day or so, you typically want to cook corn immediately so that it'll retain its sweetness.
It doesn't need to be a long cook -- a couple of minutes in boiling water, or a few minutes on the grill will suffice.
If you get your corn from a farmstand, so it was picked the same day, and you're cooking the casserole immediately, you might be able to get away without cooking it ... but it's possible that the leftovers might suffer, if the corn isn't heated sufficiently.
Also note that some people have more problems digested raw corn as compared to cooked.