Does the aerodynamic center always have to lie on the chord line?
No, there is no reason why aerodynamic center (AC) have to lie on the chord line. As the OP correctly pointed out, Thin Airfoil Theory (TAT) result indicates that the AC:


Exists, and 
Lies on the chord line 1/4c away from the leading edge.


However, this is only because the TAT makes the fundamental assumptions that the airfoil is thin, the mean deviation of the camberline is small relative to the chord, and small free-stream incidence (AOA). As shown in the diagram below, the vortex sheet is assumed to lie on the chord line instead of the mean camber line. (I should mention, however, that the slope of the mean camber line is accounted for in the theory to construct the tangent boundary condition on the airfoil). And, of course, TAT doesn't account for drag.



(Diagram cited from Anderson, Fundamentals of Aerodynamics.)

The vertical offset is small, however, at least until the drag rise associated with flow separation or when flow incidence becomes large. If there is a large vertical separation between the center of pressure and the chord, then AC will not exist and this manifests as nonlinearity in the Cm curve.

I've included the pitching moment coefficient about 1/4 chord of NACA0010, Clark Y and NLF(1)-0115 analyzed with Airfoil Tools, which were analyzed with xfoil using panel method + boundary layer equations. The plots included Reynolds number of 500,000 and 1,000,000 with Ncrit transition of 5 and 9. Note that AC exists locally where Cm has a constant slope.



For NACA 0010, AC exists up to 10 deg AOA at 1/4c; near stall, the drag rise occurs and the Cm becomes nonlinear. For Clark Y and the NLF, the AC is pretty close to 1/4 for small AOA, then shifts to a point further aft until drag rise.

Therefore, while the concept of AC is useful for theoretical derivation of stability relationships in linear aerodynamics, it's not a good enough for precise modeling. In engineering modeling, we generally measure the pitching moment (from wind tunnel) at 1/4c, and account it as a function of AOA.