What is used to ask a question when there are an unknown number or infinite possibilities for an answer. You know that there are many, many ways that exist to address your question, and you want to find out—from all those possibilities that you might not even know about—the best way.
For example: "What movie did you go to see?"
Which is used if you are choosing between two items, already defined, in a different sentence, like this:
For example: "Which shoes should I wear with this dress—my blue ones or my black ones?"
You can use which when you have a very small or limited field to choose from. Certainly use which, not what, when there are only two choices, or if both speaker and listener can visualize all the items under consideration:
For example: "Which foot did you break?"
Often, either which or what can be used for several choices, depending on what is in the speaker’s mind:
a - "Which bus goes into the centre?"
b - "What bus shall I take?"
Both sentences are fine. The speaker is probably thinking about fewer buses in sentence (a) than in sentence (b).