"He had known his niece."
Translation:Il avait connu sa nièce.
The word in question is connu, which is a past participle - not the main verb - and consequently is never conjugated for the subject, which in this case is il. So does it have to agree with il? Never. Does it have to agree with nièce? Not in this case, but not never.
A past participle agrees with the direct object if and ony if the direct object precedes the past participle. Usually this situation comes about when a direct object pronoun is used (Il l'a connue) or where a relative clause is inserted in that screws with the normal word order (C'est sa nièce qu'il a connue). But here we see that the direct object nièce actually comes after the past participle connu, so that's actually all moot; the condition hasn't been met, so there's no agreement necessary.