Rosemary (Rosmarinus officinalis) is a popular herb gardeners use to fight off insects, such as ants, and it can help deter the pests from your home when planted near the entrances of your homes and in flower and herb borders. Plant rosemary in pots scattered about porches and patios or in borders.