Hi Melissa,
Your car should normally have about five quarts of oil in the engine, and there's a pump that pulls oil from the pan. When the oil level is low, the oil can slosh from one side of the pan to the other and leave the oil pickup dry, which then turns the oil light on. When you come to a stop, the oil sloshes back to the low point of the pan and continues to get sucked up by the pump.
So basically your car is low on oil. Pull out the dipstick, wipe it off and put it back in. Now pull it out and see where the oil appears on the markings. If no oil appears, you're really low, otherwise the low mark shows when you're about a quart low. Add oil until the oil comes up to the full mark and you should be good.
Without knowing the year and engine size of your Optima I can't tell you exactly how much oil it should have, but generally a total of 5 quarts of 5W-30 is enough to refill it from completely empty.