Flavored olive oils are fun and so easy to make. But there’s good reason to take precautions. There is risk of botulism in making some types, and this seems to be particularly true of garlic oil as it has a low pH and harbors moisture. It’s believed that this combination promotes growth of Clostridium botulinum in an anaerobic environment, like oil. To be safe, here are some general recommendations to follow.
Cook the garlic in a little olive oil until softened before adding the remaining olive oil.
Once all the oil is added to the garlic, maintain a low oil temperature.
The safest bet is to store the garlic olive oil in the refrigerator and use within three weeks. If stored on the counter at room temperature, use within one week. This is not true of commercially available garlic olive oils as manufacturers are required to include acidifying agents to raise the pH level, for example phosphoric or citric acid.
As a note, many home cooks do not follow these guidelines and have no problem, but risk does exist.