If you have one engine, it pretty much has to be on the centerline. Otherwise, you'd have asymmetric thrust and you'd have to deflect the rudder, all the time, to maintain straight flight. This causes drag. Put it on the front, in a "tractor" configuration. Or on the back, in a "pusher" configuration. Or both (see Cessna SkyMaster). Or on top (see Lake Buchaneer/Renegade). Either way, put it on the centerline of the aircraft.
If you have two or three engines, you usually want those as close to the centerline as possible. In the event that one of the engines shuts down (intentionally or otherwise), you want the remaining thrust to be as close to symmetric as possible, for the above reason. Bill Lear was fond of saying that, in a twin-engine aircraft, each engine was just powerful enough to get you to the scene of the crash. Meaning that, for many twin-engine aircraft, if you lost one engine, the other engine could keep you airborne until you could no longer counter the asymmetric thrust and you lost control and crashed. This why Lear Jets all have fuselage mounted engines (as close to the centerline as possible) and the last airplane he was developing (the Lear Fan) had twin turboprop engines driving only one prop. If you lost one of the engines in THAT bird, you had less power but your thrust was still perfectly symmetric.
There are aircraft which have > 3 engines, mounted close to the fuselage. The Lockheed JetStar comes to mind, as does the Comet. Unfortunately, putting multiple jet engines next to each other causes problems with the airflow around the air intakes, which can reduce the efficiency of the engines.
In the meantime, you also have the issue of weight. Aircraft are designed so that the center of gravity (or center of mass, if you prefer) is on the wings because that's where the lift is. One of the heaviest things a modern jetliner is carrying is ... fuel. Not surprisingly, many of them have most of their fuel storage in their wings. Another of the heaviest things they're carrying is ... the engines. If you put the engines on the wings you have to have a significant-sized fin and rudder to keep it straight in an engine-out situation, but the forward-aft weight balance works out nicely. Putting all that weight on the wings also means that the rest of the fuselage is bearing less of a load, which means the structure can be, relatively, lighter.
So, for large jetliners with massive high-bypass turbofans, you want the intakes spaced out as much as possible, for maximum efficiency, and you want them close to the wings so that much of the weight and the lift are easily connected. Of course, being able to use gravity to drain fuel down, from the wings into the engines, also means the engines are more likely to get fuel if there's an electrical problems (which could shut down the fuel boost pumps).