漢字はどう正しく書くのか、どう正しく読むのか、彼らは時々迷います。
See Section 2, いったい~なのか. It is used to show perplexity
参加するのか、参加しないのか、ここではっきり返事しなさい。
See Section 2, いったい~なのか. It is used to show impatience
「白」という漢字はどんな時に「はく」と読むか、どんな時に「しろ」と読むか、首をかしげます。
彼はどの大学に入るかはまだ決めていません。
See Section 6.
I think のか used in questions (excluding rhetorical usage) generally fall into 4 categories.
1. つまり~なの(か) type
You use this の when asking for confirmation. の functions like a quotation mark, which encloses an existing proposition. This kind of の often appears after つまり.
The ~ part can be your conclusion, speculation, or simply hearsay:
(When you hear the rain) 雨が降ったの?
元気がなさそうですね。頭が痛いのですか
This の(ですか) is frequently used in yes-no questions and alternative questions.
Notes: The non-question version のだ/のです is abundantly discussed in research papers. Another related form のではないか can often used in the same context.
2. いったい/ほんとうに~なのか type
You use this の when you feel puzzled and difficult to figure out the answer.
The ~ part can be a wh-question or alternative question, which are often accompanied by いったい. It may also be a yes-no question or alternative question, which is often accompanied by ほんとうに. It is also common to use it to show your curiosity or impatience.
結局何なのですか
いったい何が問題なの
3. なんで~なのか type
A special の is trivially used in wh-questions. I think it is similar to いったい~なのか type, but the degree of perplexity is very low --- as far as you have used your brain, you can add の. This means, you can almost always add の.
どこへ行ったの
いつ始まるのですか
誰がやったの
One of the restrictions I have noticed is that you do not use this type of の when the wh-word is immediately before (です)か, such as 何時ですか, だれですか, なんでですか, nor when the wh-word modified a noun that is immediately before (です)か, such as 何時のことですか, 誰の財布ですか, etc. In other words, the wh-word must be adverbial. It follows that when you convert a ~なのですか question to ~のは~ですか form, you do not add an additional の.
Another restriction I found is that you do not use this の when it does not make much sense to use your own mind to figure out the answer, for example
お名前は何とおっしゃいますか
(A teacher asks a student) 88と99を足すといくつになりますか
(When taking the order) 何になさいますか
4. ~で~なのか type
Another special の similar to なんで~なのか, except that the なんで part replaced by a noun. ~ is a yes-no question. This の is used when the focus of the question is adverbial.
この時計は、ネットで買ったの
今日は、車で来たのですか
Thee function of this の might be similar to つまり~なの(か), which is used to express your speculation and ask for confirmation, but it is just trivially used and does not have much implication.
Just like なんで~なのか, の is not necessary in some cases.
次は高瀬駅に止まりますか?
Notes: This function of の seems related to ~のではない, and mentioned as 否定のスコープ in research books. But I disagree because の is not necessary for this function.
5. Politeness concerns
Although の does not change the meaning of a sentence, there are times you have to use it to sound natural.
As far as I know, you should usually use の in cases 1. つまり~なの(か) and 2. いったい/ほんとうに~なのか.
As for 3. なんで~なのか and 4. ~で~なのか, の is usually obligatory in plain forms (だ体), and less important in polite forms (です・ます体). When it does not make much sense to figure out the answer by yourself, you may want to or have to avoid the use of の.
I think the main purpose of using の in plain forms is to expresses your emotions, like curiosity, intimacy, etc. It seems that の and other sentence-final sentences are more common in informal and plain forms than formal and polite forms. For example, you often have to say ~だよ to sound natural where ~です is sufficient.
Sometimes, questions with の sound friendly, while those without any sentence-final particles may come off as curt and rude.
誰がした
どこへ行く
何をする
(どこへ行きますか may still be impolite because asking someone's intention is generally considered improper.)
Even when の is not necessary, some people consider using の as humbler and politer.
先生、この漢字はどう読むのですか
But sometimes, using の when it is unnecessary may make you sound impatient, pushy, or like interrogating.
The Japanese language itself is changing over time. It seems that in contemporary usage, 何で, なぜ and どうして are always paired with の. But this tendency was less prominent several decades ago.
6. Indirect Questions
You can follow the same rules above. But indirect questions can be considered as abstract nouns, so sentence-final particles are not really necessary. の can be omitted.