You have asked quite a number of questions in your post so let's tackle it one by one.
Why does the oxidation take place at that particular nitrogen atom?
To understand this, we first need to acknowledge that peroxyacids $\ce {RCO3H}$ are electrophilic oxidising agents. Specifically, the oxygen atom attached to the $\ce {H}$ is the electrophilic atom. From the frontier MO perspective, the reactive LUMO of the peroxyacid is the $\ce {O-O \sigma^*}$. This implies that the most nucleophilic nitrogen atom is likely to be favourably oxidised.
In fact, the oxidation of pyridine, which is a chemical species containing a nucleophilic $\ce {N}$ atom, to form pyridine $\ce {N}$-oxide using peroxyacids is well-known. It is documented by Clayden, Warren & Greeves (2012) on p. 730 as a method of increasing the reactivity of pyridine towards both electrophilic and nucleophilic aromatic substitution reactions. Notice that the bottom $\ce {N}$-containing ring actually resembles a pyridine fused with another benzene ring. However, note that the lone pair on $\ce {N}$ is not delocalised into the ring(s). Thus, there is no significant decrease in nucleophilicity of the bottom $\ce {N}$ in this compound relative to pyridine's $\ce {N}$ atom, suggesting that oxidation of the peroxyacid can very likely take place there.
Of course, we must be thorough in our analysis and also take a look at the relative nucleophilicities of the other two $\ce {N}$ atoms. Immediately, we will notice that for the $\ce {N}$ atom that appears to be making 3 single bonds has a lone pair that is heavily delocalised, in both the benzene ring below and the 5-membered ring it is in. Thus, we can eliminate the possibility of the the oxidation taking place at that nitrogen atom.
For the final top-most $\ce {N}$ atom, the lone pair may appear to be of the same nature of that of pyridine, i.e. held in an $\ce {sp^2}$ hybrid orbital. However, note that the presence of the adjacent $\ce {N}$ atom may result in inductive withdrawal of electron density from that $\ce {N}$ atom, decreasing its nucleophilicity.
Ultimately, I believe this first part is trying to test students if they are able to relate the structure and reactivity of pyridine towards oxidation by peroxyacids to the bottom pyridine-like ring. If students can make the connection, then they would instinctively know that the oxidation has taken place at that $\ce {N}$ atom.
From A to B what happened?
Well... There are a number of things which happened here. The most obvious being the first step: Basic hydrolysis occurs, with the leaving of $\ce {EtO^-}$. The next step is an electrophilic aromatic substitution, with the acidic deuterium ions as the electrophile. For pyridine $\ce {N}$-oxide, the 2- and 4-positions are activated towards EAS reactions. This can be shown simply by drawing the resonance structures of the compound with an $\ce {N=O}$ double bond. Similarly, the EAS takes place at the 2-position, relative to the $\ce {N}$-oxide group. It is difficult to explain why it doesn't take place at the 4-position as well. In general, for this type of structure elucidation questions, we would need to predict structures by looking at the resultant structures as well, especially if they are given. In this case, we see that only the 2-position has deuterium substitution taking place and we should simply leave it as that. Of course, if anybody has a good explanation for why that is the case, please propose it. Also, the other positions on the other rings may not be activated enough for the substitution to take place. Thus, we do not see substitutions taking place at those positions. Again, I am not able to provide a rigorous explanation for why that is the case.
Finally, the third step with $\ce {H2O}$ effectively makes the pH of the medium neutral again and also changes the carboxylic acid group from $\ce {COOD}$ to $\ce {COOH}$. This is simply due to a concentration effect. The high concentration of $\ce {H2O}$ simply pushes the equilibrium towards species containing $\ce {COOH}$.
What about from B to C?
From Wikipedia, it seems that $\ce {B}$ to $\ce {C}$ is simply a reduction step. The ammonium formate decomposes to give $\ce {NH3}$, $\ce {H2}$ and $\ce {CO2}$ in the presence of $\ce {Pd/C}$. The hydrogen gas evolved then gets adsorbed onto the palladium catalyst, where it can reduce the $\ce {N}$-oxide to give back the original $\ce {N}$-heterocycle.
And the last step involving conversion of C to the final product is as you have proposed.
Reference
Clayden, J.; Greeves, N.; Warren, S. Organic Chemistry (2nd ed.). Oxford University Press: New York, 2012.