Yes, the plant can be compost if not diseased. As for dirt, several options. Part depends on size of pot and how much soil. Up to 12" pot is mostly used up by the basil, and you will see roots through out pot. Larger a different story.
I have an enriched dirt pile aka compost. Left over (not diseased) pot stuff goes in there along with veggie scraps. Worms are very happy! I was negligent this past season, but usually by spring start using one side, shift to other with fresh additions. Older side gets sifted to use in ground and pots.
With larger pots I usually leave stems and roots in pot to decompose or whatever. In spring, pull out top few inches, throw that in pile, build up with fresh mix, plant. With this, most of the soil in pot stays untouched. I am working towards a living soil in the containers. Some say it won't work, but I defy that!