I know that if you push a garlic clove into the soil beside your tomato plants then it can get rid of some pests such as red spider mites. You can also buy garlic sprays that are good insect repellents. I don't know if actually planting garlic adjacent to your tomatoes would work but it's certainly worth a try.
For the last three years, I've planted onions and cloves of garlic in containers holding tomato plants..can readily testify that the method WORKS. Noticed plants were healthier, more disease resistant and weren't prone to "bug infestations" as they had been previously. There hasn't been a good garlic crop, but the onions reach store-quality size, and the tomatoes don't mind sharing space with them at all. This is a form of "companion planting" where one type plant's actually aiding the other for best results: the alliums actually release substances into the soil(s) that are highly beneficial to those around them. You can use store-bought clumps of garlic: just break off the largest outside cloves, plant 3-5 around bases of tomatoes (about 1-2 inches deep); plant onion bulbs (just deep enough as to where tops are covered) inbetween if so desired, and that's it. You WILL see a differance by season's end!