The thermal conductivity k of the iron-arsenide superconductor K-Ba122 was measured down to 50 mK in a magnetic field up to 15 T, for a heat current parallel and perpendicular to the tetragonal c axis. In the range from optimal doping (x ~ 0.4) down to x = 0.16, there is no residual linear term in k(T) at T = 0, showing that there are no nodes in the superconducting gap anywhere on the Fermi surface. Upon crossing below x = 0.16, a large residual linear term suddenly appears, signaling the onset of nodes in the superconducting gap, most likely vertical line nodes running along the c axis. We discuss two scenarios: 1) accidental nodes in an s-wave gap, resulting from a strong modulation of the gap around the Fermi surface, in which minima deepen rapidly with underdoping; 2) a phase transition from a nodeless s-wave state to a d-wave state, in which nodes are imposed by symmetry.