Yes, you can compost the tomato and pepper plants. If your plants were healthy all summer, no problem. For quicker action, you may make a pile of them and chop them with a mower. Anything green gets handled that way by me. I mix the plants with dry maple and ash leaves and run them through a bagging mower. Mixed with the shredded leaves, it becomes a hot pile which quickly kills any leftover bugs or possible diseases. The important thing is to get those dead or dying plants out of the garden. Then there is no place for any problem insects to winter over.
Martin