The amount of light required to achieve the same exposure is proportional to the print area. That is the same as saying it goes with the square of the linear dimension. This is a approximation that is reasonably valid once the print is a few times larger than the negative.
Let's say your example with a height of 8 results in a 8 x 12 print area. Now you raise the enlarger so that the same image results in a 12 x 18 print area. 8x12 is a area of 96, and 12x18 a area of 216. At first approximation, roughly the same light will be spread over 216/96 = 2.25 as much area. That means the larger print will be exposed Log2(2.25) = 1.2 f-stops less if all else is kept the same.
In this example, you compensate by using f/8, or 18 seconds exposure, or some combination to make up for the larger area.
As I said earlier, this is a approximation that is close enough as long as the print is a few times larger in linear dimension than the negative. Most of the time that is the case, so I won't go into detail about how to correct for that.
A long time ago when I was still using a enlarger, I made myself a cardboard slide rule that showed me exposure times as a function of enlarger height (mine had a numbered scale), f-stop, which lens (I only had two), which attenuator, and general -2,-1,0,+1,+2 overall exposure. Instead of doing the math, I derived these from direct measurements with a light meter. It was quite handy.