Keep a clean camp.
If you cook outside, be sure to clean up all your spills and any grease as much as possible. Clean the grill if it's on the fire ring; if it's your portable, clean it and put it away.
If you cook inside--again, clean up thoroughly.
Take your food trash to a trash can or dumpster after clean up.
Do not leave food visible on a counter to tempt a bear to take a swipe at a window while you are away.
Never put scraps, used napkins or paper goods (or anything else) in the fire ring to burn later.
Never leave anything unattended on an outside table that remotely resembles food, for even a few minutes--not even cans of soft drinks. Even if bears don't show up, squirrels and other critters can make a big mess.
Black bears are chow-hounds, and generally easily frightened off. But don't set up a situation to attract them, and you will likely never see one do anything but stroll through. Just don't do anything that remotely resembles getting between a sow and cubs.
Grizzly country requires all of the above precautions, but with even more care.
If a grizzly decides to stroll through, sit tight and still wherever you are. They do not scare off readily. Generally if you have a clean camp they are not interested in you. But they can be grumpy if annoyed.