First I assume you are referring to hornworms that feed on the tomatoes, peppers and other related plants in the veggie garden? There are many hornworms out there, but the others are less frequently seen and feed more on trees than annual plants.
In answer to your question - good you asked. If they are right from your garden off the tomato plant then NO! Believe it or not, every plant in the Solanaceae family (tomato, potato, pepper, petunia, datura and others) are poisonous at certain stages and certain parts.
Hornworms are often fed to chameleons and other herps but ONLY if they have been reared on an artificial diet which you can buy online.
here is an article on rearing hornworms as well as places to purchase hornworms
Does this mean that if fruit flies eat rotting tomatoes, they are bad for my babies? What about pinhead and larger crickets eating potatoes? Right now, my fruit flies are eating peaches, watermelons, and bananas. Are they ok?
I guess I cannot comment directly on the fruit flies but I will say a couple of things. The ability of alot of animals to eat rotten food items is usually in relation to the microbes in thier digestive tracts. These microbes make breaking down the food item possible. It is very doubtful that the ill effects of this rotten food item could then be passed on after being broke down. The point at which most people consider say a fruit has gone bad is usually in relation to it's color. Keep in mind that alot of fruits are very high in iron. These fruits are not actually rotting at this point they are merely oxidizing. It is no different then sanding some steel bare and then leaving it out, it will rust. Most fruits when in a ripening stage will secert ethly from a chemical break down that happens when removed from the tree (or plant). This helps the fruit from rotting prematurely. In refrideration you slow this process. In nature this process would slow if the weather was cool. If it is hot it will break down faster. This will give the seeds better odds of turning into a plant. This means the seeds will finally get out of the fruit and into the ground when conditions are more optimal. Ethly is the fruits natural preservative.
I have read of other people feeding similar food items to fruit flies for neonatal care. I have no real experience with chameleons at this stage of development.
As far as the tomatos and potatos, They are the "Fruit" of the plant, and non toxic. The plant itself is toxic. So if you are feeding tomatos and potatos to your feeders it should be ok.