LM317 TO-220 heat sinking: Junction to case or junction to pad?
According to the note just below the thermal data table from that datasheet:


  For packages with exposed thermal pads, such as QFN, PowerPAD™, or PowerFLEX™, \$\theta_{JP}\$ is defined as the thermal resistance between the die junction and the bottom of the exposed pad.


The way I interpret that:



So if you are attaching the heatsink in the normal way, on the back, against the pad, use the junction to pad thermal resistance.