Details vary from place to place, but the standard legal rule in the United States is that if you want to bake some cookies in your house then you're free to do so. You can also give the cookies you baked to friends, family, and neighbors. You can bring the cookies in to work to share with coworkers. You're also free to exchange the cookies in a wide range of contexts. You can use them as your contribution to a pot luck, for example. But what you typically can't do with your cookies is trade them for money. If you have a bunch of fresh baked cookies but need some money, and someone else wants to give you money for cookies, you're out of luck. You baked the cookies at home, not in a commercial kitchen.
But in Washington State, at least, things are changing and a recently passed Cottage Food Act that will come into effect this summer will give the blessing to "small, home-based entrepreneurs looking to sell cakes, cookies, jams, jellies and other so-called 'low-risk' foods."
It'll be interesting to keep an eye on this. Will the state's jam-eaters be stricken with waves of illness? Or is going to turn out that people eat food cooked at home all the time, and it'll basically all be fine? Absent the terrible economy this probably wouldn't be a big deal one way or another, but with things being what they are these kind of barriers to gainful employment matter a fair amount.