Does it matter where the battery is mounted? Or is it best to have the centre of gravity aligned with the propeller plane where the thrust is generated?
It depends on what kind of stability you're after. Nicolas Petit wrote a paper on this several years ago, the graphics below are taken from Pages 4 and 5.
The summary is that a higher CG is better for x-y position stability, a lower CG is better for speed stability.
Before we begin, let's assume we're only talking about a drone flying purely forward and so all dynamics are related to pitch.[*]
Second, let's define the CG, center of gravity, relative to the aerodynamic center (similarly to in https://aviation.stackexchange.com/questions/19388/what-is-the-difference-between-centre-of-pressure-aerodynamic-centre-and-neutra). The aerodynamic center is the idealized point where all the drag forces are acting around it evenly. In other words, it can be thought of as the spot where half the drag rotates the quadcopter into a pitch up orientation, and half rotates it into a pitch down orientation.
Here's the relevant image. It shows forward flight, and that's the same as position-holding flight with a backwards wind.[**] The red arrow is for when the CG is above the aerodynamic center, and the blue arrow is for when it's below the aerodynamic center.
Top-heavy CG: increases position stability, decreases velocity stability
When the CG is above the the aerodynamic center, the drone tends to tilt forward when there's a gust of wind. This ensures positional stability, because as the drone is pushed backwards it naturally leans forward which reduces the speed at which it accelerates backwards.
However, since the CG is above the aerodynamic center, when flying forward the drone wants to trip over its AC and pitch even more forward. This means that forward velocity is somewhat underdamped, results in a less positive-- or even negative-- feedback cycle.
Bottom-heavy CG: decreases position stability, increases velocity stability
In this case, the CG is below the aerodynamic center. When there's a sudden gust which destabilizes the drone, the drone tilts away from its holding position, which combined with the gust's force, accentuates the positional error.
But on the other when flying steadily forward the drone tends to want to pitch back toward the vertical, instead of tripping over its own feet. This means that forward velocity is well damped without a positive feedback cycle.
[*] Roll functions exactly the same way, but it's distracting to write "pitch/roll" each time we're talking about a rotation. [**] This is a basic tenet of aerodynamics and fluid flow, which is that it's indistinguishable if the object is moving through the fluid or the fluid is moving around the object.
As far as I know, it doesn’t make too much of a difference in regards to flight stability because of something called the Drone Pendulum Fallacy, which describes how the drone rotates about the centre of mass, not from the point at which the thrust is created as illustrated below in the photo from the Drone Pendulum Fallacy website:
In my experience, it may affect handling - many racing pilots prefer bottom mounted whilst many freestyle pilots prefer top mounted, however this is down to the way the quad handles and so is really personal preference.
There are other factors you may want to consider - for example a top mounted battery brings the centre of mass closer to the thrust line, and it can also balance out the impact of having a GoPro on your quad. A top mounted battery also means you don’t have to land on your battery so takes away that risk.
However, a top mounted battery requires more space than a bottom mounted one (assuming you also want to use a GoPro).
Oscar Liang talks about this on their website, so I recommend taking a look there to help make up your decision.