On an Earth-like planet, an intelligent species evolved in symbiosis with another species that lives in their digestive system and act as the microbial gut flora in humans do. What implementations of macro-scale creatures (such as insects or something similar) would allow them to take over as much of the functionality in their host's digestive system as possible?
(...) instead of having bacteria and enzymes break down foood, it would be a lot of small insects or insect-like things living inside of a creature's stomach (...)
The stomach is a very harsh environment for most bacteria. Usually when something manages to live there, it's Heliobacter pylori, which gives you stomach ulcers. Some worms pass through the stomach alive, but practically always in some egg or larval stage where they are protected against the acid. They mature somewhere else, usually the bowels or liver.
The one place in the human digestive system where multicellular lice can thrive without damaging the host (too much) is the intestines. Insects could live there, going in and out by yes exactly that passage.
When we lose our gut flora, we get diarhea, which is not nice. In an environment where there is no such flora, land vertebrates could develop a symbiotic relationship with insects that enter their intestines and eat or remove the feces. Good candidates for this are non-flying eusocial insects such as ants and termites (the latter build their homes out of excrement anyway), or dung beetles.
If you don't like the idea and really want a stomach replacement... Imagine an animal whose stomach is innefective as a species trait. The function of the dtomsch is to break stuff at a molecular level, mostly protheins. Insects could either visit or live in that creature's stomach, eating stuff and... Well... Leaving out very aminoacid rich feces. The insects provide the breakdown otherwise given by a stomach, while the host provides shelter and a toilet.
Intestinal worms are properly called “helminths,” which most dictionaries will tell you are parasites. Exploiting their hosts, draining resources, sucking the life out of the body – that’s what parasites do, by definition...Helminths have been a part of the ecosystem of the body for so many millions of years that they have become an integral part of that system. Mutualistic helminths help regulate immune function, stimulating our body to build regulatory networks of immune cells that decrease general inflammation without hurting our immune system’s ability to respond to danger. In addition, these helminths produce their own array of anti-inflammatory molecules and give our immune systems much needed exercise, all of which decreases inflammation. (ref)
Our existing Earth systems are not quite what you're looking for. Some worms (the kind that change into moths and butterflies) are insects, though helminths are not. You could change this for your story. Intestinal worms have their own microflora so even if the worms do not take over the jobs of gut bacteria, they could (in an alien ecosystem) be a necessary intermediary.
It's a Russian nesting doll of sorts: Parasitic bugs that live in the human gut have their own set of gut bugs inside their intestines... "We were amazed to find that whipworms have their own distinct microflora" and — similar to humans — that the bacteria appear to aid in the parasite's health...The bacteria inside the parasite's intestine appear to be necessary for its growth...What's more, whipworms appear to be able to alter the gut bacteria of their human hosts to aid in their own survival. (ref)
If you really want an insect, create an insect worm that only goes through metamorphosis after leaving its host. Or expand your label of "insect" to include worms. Multiple species of worms on Earth are already adapted for the gut of higher animals so it would not be a stretch to create a species that fits your other needs.
Symbiosis means living together. There are different types of symbiosis: (1) mutualism - both organisms benefit; (2) commensalism in which one organism benefits from the interaction and the other is unaffected by the interaction; (3) amensalism in which one organism is harmed by the interaction but the other organism is not affected (no benefit); and (4) parasitism in which one organism is harmed and the other benefits. Predation is sometimes also considered a symbiotic relationship.
Mutualism and parasitism are all possible symbiotic relationships that would work for your scenario. If your sentient symbiont imparted some evolutionary advantage to its host insect then the relationship would be mutualism. If the symbiont simply used the insect as an intermediate host for its larvae and took sustenance from it without providing any advantage then that relationship would be parasitic.
It seems difficult to me to come up with a situation that would make the evolution of a sentient mutualistic organism. Obviously there are extant examples in science fiction (DS9's Trills) but you will have to think this through very carefully to make it believable. You have to imagine the conditions that would warrant the evolution of the symbiosis first. Actually that WILL BE the hardest part, I think.
After that you can use a basic Parasitology textbook from your local library as a starting point for coming up with a design for the details of your sentient symbiont be it a mutualist or parasite. The text can give you numerous examples of parasite life cycles and interactions with hosts. All of this would need to be worked out closely to be convincing. Certainly there are a plethora of life cycles, physiologies, and morphologies that could be taken from examples here on Earth. Those details could make your stories interesting.
I hope this helps.