Where do you get the medicine?

Literal

Medicine [topic-は] where [at-で] receive-[explanatory-んです][Q-か].

~んですか is the explanatory/inquisitive variant of the polite question — it asks for explanation or confirmation rather than neutral information ('so where do I get it?'). The verb 貰う ('receive') is used loosely here to mean 'pick up, get' — a casual substitute for 受け取る. で marks the location where the receiving happens.