How is the center of mass controlled in planes with multiple tail engines? My understanding is that, for flight stability, the center of mass must be ahead of the aerodynamic center.

There have been some rather big jets with 2 or 3 jet engines in the tail. Tu-154 and Boeing 727 have 3 in the tail. The DC-9 has 2, and there seem to be countless small private jets with twin engines in/near the tail, like the Learjet 45.

Another example is the Concorde and Tu-144 which had a whopping 4 engines very near the tail. If I'm not mistaken those were some extra-heavy engines too since they had to be supersonic.

So if we're putting the heavy engines in the tail, what is done to compensate? Do they just use ballast in the nose? How is the center of mass kept under control?

A few more details: Engines at the tail requires stronger (heavier) empennage, which also adds more weight in a direction we do not want our CG moving. Wings still hold the fuel, so moving the large wing/fuel mass backwards just to move the aerodynamic center backwards doesn't seem like enough.

I noticed that those tailed trijets and large tailed twinjets seem rather old. There don't seem to be any new designs of large commercial aircraft with tail jets. This makes me suspicious that the configuration is inefficient. However, small private jets seem to always be tailed twinjets, whether new or old designs.
The wings are placed sufficiently far aft.

Yes, moving the wings aft moves the C/G aft as well, but since the fuselage has some weight, eventually the centre of lift overtakes the centre of gravity and there you place the wings.

A slight problem is that C/G of cargo gets quite a bit ahead of the C/G of the airframe, causing a large difference in overall C/G position between empty and loaded aircraft and a larger horizontal stabilizer is required to maintain control over the whole range. And that, of course, reduces overall efficiency.

When you look at aircraft with tail-mounted engines, you'll see that it has wings further aft compared to one with wing-mounted engines.

Note that Concorde additionally could transfer fuel between forward and aft fuel tank in flight to adjust the C/G in flight to reduce the needed deflection of the elevators. But that was not because of the overall aft C/G—the centre of lift was correspondingly far aft—but because the centre of lift moves quite significantly aft in supersonic flight.