The motion of the Sun in the direction perpendicular to the Galactic plane is deduced from a mixture of measurement and theoretical calculation.
The measurements are (i) deducing the Solar System's current position and speed with respect to the galactic plane (see How far is the Earth/Sun above/below the galactic plane, and is it heading toward/away from it? ) and (ii) deducing how much mass is present in the galactic plane which acts to accelerate/decelerate the motion of the Solar System.
From there it is a relatively simple application of Newtonian mechanics to work out what the motion of the Sun will be in the future (and where it came from in the past). The solution is an oscillatory motion above and below the plane with an amplitude of about 100 pc and a period of 70 million years.
A flavour of the calculation can be done analytically using some simple approximations.
Very roughly, you can characterise the density in and around the Galactic plane as $\rho_0 \exp(-|z|/h)$, where $z$ is the height above or below the Galactic plane and $h$ is a scale-height of perhaps 200 pc or so and $\rho_0$ is the density at the plane mid-line.
Applying Gauss' law for gravity, assuming the Galactic disc is uniform on radial scales of thousands of parsecs (so looks effectively like an infinite plane when you are close to it), then
$$g(z) \simeq -2\pi G\int^{z}_{0} \rho\ dz = -2\pi G \rho_0 h[1-\exp(-|z|/h)]\ .$$
Thus, when a star (e.g. the Sun) has $|z|>0$, there is a restoring acceleration that acts towards the Galactic plane at all times.
Even more roughly, we can approximate $\exp(-|z|/h) \sim 1-|z|/h$, which simplifies the acceleration to
$$ g \simeq -2\pi G\rho_0 |z|\ .$$
This is just simple harmonic motion of the form acceleration $= -\omega^2 |z|$ and thus stars oscillate up and down through the Galactic plane, with a period of $2\pi/\omega = (2\pi/G\rho_0)^{1/2}$.
The stellar mass density near the Galactic plane is something like $0.1M_\odot$ per cubic parsec. This gives an oscillation period of $\sim 100$ million years. A more accurate calculation gives more like 70 million years.
To estimate the amplitude of the motion requires a measurement of the current motion of the Solar System with respect to the galactic plane. This is currently estimated as about 7 km/s directed out of the plane and the Sun is currently about 20 pc above the plane (see here). Again, assuming simple harmonic motion, then the sum of potential and kinetic energy is constant
$$\pi G \rho_o z^2 + \frac{v^2}{2} = {\rm constant}\ .$$
Substituting $z=20$ pc and $v= 7$ km/s we find a constant of $2.5\times 10^7$ J/kg. Then setting the speed to zero this is the potential energy per unit mass at the highest/lowest point of the oscillation, which yields an amplitude of 136 pc.