He never cared for sleeping, not when there were people he could talk to.
In the sentence, after comma, "not when" is to me quite unusual. Would you give me a comment and the other usage?
I don't think the current answers adequately answer the question.
There's two parts to this. First, he never cared for sleeping. When doesn't he like to sleep? The answer is "when there are people he could talk to [instead of sleeping]".
The idea being shared is that when people are around, he would rather talk to them than to sleep.
The "not when" is kind of tying into the "He never". They both refer to the same thing, his dislike of sleep at that moment.
"Not when" creates a contrast to what was said earlier (usually before "but" or with "though"), emphasises or adds clarification to the previous statement. Often it is either preceded by "but" or separated by a "comma" from the previous statement.
In your sentence it's a mere emphasis with clarification, the "not when" focuses on the information.
It is possible to understand not when... as a refinement of never, a condition placed upon never.
It can be repositioned:
He never—not when there were people to talk to—cared for sleeping.
The not when is connected semantically to the negation of the predicate [cared for sleeping], but is otherwise detached.
She never drank soda-pop, not when fruit juice was available.
She drank soda-pop sometimes, but only when fruit juice was not available.