Good Morning,
I would tend to believe that the lens is the problem. The lens is responsible for focusing the image on the sensor, if you are getting a poorly focused image on the sensor, the body really can't do too much with it, other than provide a poor image. There can be plenty sources of error in the combination of body and lens.
Have you tried manual focusing at all? Use LiveVew and then press the [info] button and rear wheel in order to zoom in for focusing. Also use f8 to get a fat depth of field (at least initially). Maybe even attach the USB or video cable to a larger screen and see how well you can focus with the lens.
Are you comparing apples to apples - an equivalent type/quality Nikor lens on the D7000 to the K5/18-135 combination? Comparing a prime to a zoom, or one of Nikon's best lenses to a Pentax consumer grade, would not be a fair comparison. Also, the D7000 does have a better AF system than the K5, so is the comparison at least to start in a well lite environment? But, you know that both the D7000 and the K5 have the same sensor, so they are pretty much equivalent cameras to a large degree.
I recently acquired (new) a Sigma 8-16. It too didn't "feel" right. I dialed in the maximum 10 units of correction. It was a bit better, but ... I sent it in to Sigma (actually CRIS who does Sigma warranty work), and it needed yet another 35+ units of correction. They also matched the lens to the body, so it is essentially as perfect as it can get. It nails focus (given sufficient light) every time now. So the combination of body and lens can be off. Should not happen - but it does. Frustrating - yes....
Post some images....