According to HowStuffWorks, basil plants are effective in keeping flies away from specific areas. Planted in beds next to doors, basil discourages the insects from entering houses. Using containers is a convenient way to place the plant in many locations, such as near home entrances and around patios.
A bunch of fresh-cut basil taken on a picnic keeps the flies away from an outdoor meal. In addition, basil is avoided by mosquitoes.
There are other herbs that repel flies, as well. Bay leaves keep them away, as does pennyroyal. However, pennyroyal needs to be used carefully, because it is dangerous if ingested by children or pets. Tansy is also used as a deterrent for flies.