They are stored in exif tags in the raw file. (See link
here, half way down the page under "Pentax LensCorr Tags")
You can look at tags by uploading a photo
here and searching for 'correction'
If you use the Pentax supplied SilkyPix it might use the correction information you have set, but I know that when I open the raw DNG in DXO it doesn't use the in camera corrections and I apply the DXO correction files it loads for camera / lens combinations. (Probably similar for Lightroom)
In camera lens corrections only works with specific later Pentax lenses (most DA / DA* lenses I believe). Lens corrections will not work with old manual lenses or third party lenses (Tamron, Sigma, etc) One advantage of DXO is that they have a good set of correction files for many common lenses that Pentax cameras doesn't have lens correction for. (Tamron, Sigma, Samyang).
Another advantage if you use raw and turn off in camera lens correction is that you avoid the 1 second delay after taking a picture when it process the corrections. (Most important to me since I like to zoom in on the image preview somewhat often, and if you turn the back e-dial before the lens corrections are finished you end up changing your aperture setting without realizing it.)