To say "thank you" to your dance partner is a coded way of saying, "I want to stop dancing now." If you want to express your appreciation for the dance, but you want to keep dancing with this partner, use words or an expression other than "thank you.".
The cortina (the non-danceable interlude between sets/tandas) is the customary time to change partners. However, it's entirely OK to dance more than one tanda with the same partner, and it's equally OK to stop dancing before the tanda or even before the song is over, if you are sufficiently uncomfortable for any reason. Maybe they're throwing you around, maybe they smell bad, or maybe you're just getting a blister on your foot. Whatever the reason, just stop, explain whatever you want, thank them, and leave the dancefloor.
That said, there is truth to the saying that "Everyone sees everything on the dance floor," and ending a dance early, especially in the middle of a song, is potentially enbarrassing. So if you don't INTEND to embarrass them, it is sensitive to make up some excuse, like your feet hurt, perhaps feigning fiddling with your shoes to lend credence, and let them escort you off the dancefloor amicably.