If you already owned some Sony glass, you'd probably wanted to stay with Sony. As you don't want to stay with Sony, I assume that you don't own much of their glass yet. In this case you are still free to choose whatever brand you like.
First choose the lenses you like. Think about what lenses you want to buy in two or three years. Buy a camera body and a good lens that you really like. D7000 or K-5 alone will not automatically deliver better images.
Choose Pentax if you want to use Pentax Limited primes (really lightweight and small, good image quality), or if you are attracted to their DA* lenses (high IQ and weather resistant), or like their relatively cheap, but weather-sealed zooms (WR-series). Or if you like Pentax ergonomics in general (I happen to like it more than that of Nikon), or if you want to have built-in image-stabilization that works with any lens or use slightly higher ISO of K-5, or if you shoot mostly outdoors and need a weather-sealed body.
Choose Nikon if you want to enjoy better retail experience (with Pentax you'll likely have to buy everything online) and have wider choice of glass and accessories. Choose Nikon if you're thinking about upgrading to a full-frame camera in the future (with Pentax the next step is medium format, a completely different system*).
P.S. Consider spending this money on some Sony glass instead if you already own a Sony body. You will be surprised how much better your old camera can do, if coupled with a decent lens.
* Pentax does have 2 Full Frame bodies on the market in 2019. The K1 and the K1-II so you have one more reason to choose Pentax.