In D&D 5e, when a creature is summoned through the bag of tricks or other magical means, can you heal these allies? Or are they meant to not be healed but just used until their expiry?
You can heal summoned creatures
For example, cure wounds specifies:
A creature you touch regains a number of hit points equal to 1d8 + your spellcasting ability modifier. This spell has no effect on undead or constructs.
A summoned creature is still a creature. You can heal it with any spell that normally heals creatures.
This still works for the Bag of Tricks, which summons a "creature". Note that as per the Dungeon Master's Guide errata, the creature disappears eventually:
The creature vanishes at the next dawn or when it is reduced to 0 hit points.
There are no special rules for conjured or otherwise summoned creatures. They are affected by spells and other effects like any other creatures, and accordingly can be healed by healing spells.
The spell or magic item determines for how long the summoned creature stays around. For a bag of tricks, no duration is given and therefore the creatures apparently stay around forever until they are killed.