Which of the following sentences is correct?
- What medicine should I take for neck pain?
- Which medicine should I take for neck pain?
The difference is simply that which X? more strongly implies that the speaker already knows the range of possible answers. This becomes more obvious if we consider something like...
1: What is your name?
2: Which is your name?
...where #1 is a perfectly ordinary question that people ask all the time. On the other hand, #2 would only occur in a context where the speaker has in front of him a list of people's names, and he knows or assumes the addressee's name is somewhere on that list.
You might therefore think of this usage of which as equivalent to what one out of these possibilities.
Note that this isn't a "hard-and-fast" usage distinction. It's true that my example #2 would probably never be used unless there really was an actual list, but OP's example #2 could occur even if the speaker had no idea what possible medicines might be available / suitable (but he assumes the pharmacist has a concept of such a "list", even if it's only in his head).
I should also point out that which doesn't necessarily imply expectation of a single answer. OP could have asked Which medicines should I take? - either expecting to be given a "shortlist" of products from which he might select one, or allowing for the possibility that the pharmacist might say You should take product A for immediate pain relief, and product B to reduce the inflammation and actually cure the problem.
Both are correct. Using the first question you ask for information.
What medicine should I take?
Using the second one you make a choice (even only meant).
Which medicine should I take?