There are times when cornstarch is a perfectly fine substitute for flour, and times when flour works better to thicken a sauce.
Unlike flour, cornstarch has no real flavor to mask, results in a shiny, glossy sauce and it has twice the thickening power of flour–so use 1 tablespoon of cornstarch for every 2 tablespoons of flour your recipe calls for.
However, if your sauce has a lot of acid, such as lemon juice or vinegar, you are better off with flour, which isn't "broken down" by the acid. Also, sauces based on egg yolks, butter or other fat, won't thicken as well with cornstarch as they will with flour.
For more information on substitutions, see our guide to Ingredient Substitutions.