As to whether there is a term for using a different first letter for a nickname, the answer is no. The best description is probably letter swapping. The term for a name produced by the general phenomena is hypocorism.
In a sense, you are describing a hypocoristic rule. Some rules have particular names. For instance, dropping the initial syllable(s) is known as anacope and dropping the final syllable(s) is known as truncation (both can occur, e.g. "Liz" from "Elizabeth").
In the case you describe, however, the rules are labeled for what they are: "replace initial W with B (bilabial fricative with stop)", "replace initial H, R or nothing before a vowel with N or reduplication of middle consonant", "replace initial M with P (feminine names) (nasal with non-nasal)".
As to why or how this phenomenon occurs, there are a few theories.
The 1850 equivalent of ELU offers this on the "Origin of the Change of 'Mary' into 'Polly'" :
This change, like many others in diminutives, is progressive. By a natural affinity between the liquids r and l, Mary becomes Molly, as Sarah, Sally, Dorothea, Dora, Dolly, &c. It is not so easy to trace the affinity between the initials M. and P., though the case is not singular; thus, Margaret, Madge, Meggy, Meg, Peggy, Peg—*Martha*, Matty, Patty—and Mary, Molly, Polly and Poll; in which last abbreviation not one single letter of the original word remains: the natural affinity between the two letters, as medials, is evident, as in the following examples, all of which, with one exception, are Latin derivatives: empty, peremptory, sumptuous, presumptuous, exemption, redemption, and sempstress and again, in the words tempt, attempt, contempt, exempt, prompt, accompt, comptroller (vid. Walker's Prin. of Eng. Pron. pp. 42, 43.); in all which instances however, the p is mute, so that "Mary" is avenged for its being the accomplice in the desecration of her gentle name into "Polly." Many names of the other sex lose their initials in the diminutive; as,
and probably many others; but I have no list before me, and these are all that occur.
The gist is that certain letters have an "affinity" and become interchangeable. I'm not sold on this idea, personally.
Peter McClure, who appears to have done earlier research on English names, has an article on the OED site about English personal names. The article notes:
In late medieval England there was a much greater variety of hypocoristic or pet forms than in modern times, perhaps reflecting the competitive nature of relatively small, close-knit communities. [. . .]
Rhyming pet forms were also popular, notably for short forms of male names in R-, like Ralph, Richard, Robert, and Roger, where substitution of initial R- by D-, H-¸and N- produced Daw, Haw, Dick, Hick, Dob, Hob, Nob, Dodge, Hodge, and Nodge. [This makes me think of the Name Game.]
Pet forms of names beginning in a vowel were often given a prosthetic consonant, e.g. Ned and Ted for Edward or Edmund, and Bib, Lib, Nib, and Tib for Ibbe, which is short for Isabel.
It seems reasonable to conclude that as middle names came into fashion and the general name-stock grew, the need for such personal names decreased.
A thread about nicknames ascribes this phenomenon (at least partially) to baby-talk:
Peggy, Polly and Patsy belong to the M-P linguistic pattern. M and P are
made with the lips and are some of the first sounds an infant makes.
A similar case could probably be made for "Robert" -> "Bob" -> "Bobby". This is suggested in an (almost entirely unreadable) archived dialect thread
Thus, "Robert" may get rendered into "Wob" (like "Rob"), which is a short bilabial step to "Bob." The same process seems to happen in the change from "William" to "Bill." [...]
Re: Meg/Peg Margaret--[trunc.]-- Meg-- Peg--[dimin.]-- Peggy As in Mary-- Molly-- Polly There seems to be a tendency for stops to replace nasals (as above) or liquids (as in Richard-- Dick, Robert-- Bob) or of course fricatives (Theodore-- Ted) in this process of hypocoristicism.
That conversation ends on an interesting note:
I remember reading years ago about either a Princess Margaret or Queen Margaret whose name was eventually transformed to the shortened Peg. It had nothing to do with vocal shifts. There was another reason, but I don't remember what it was. It was a logical reason concerning word derivation rather than vocal derivation.
So, the conclusion I've come to is that it's mostly a matter of phonetics. There isn't a particular reason why (e.g. why is the Northern cities vowel shift occurring?). Since at one time, most people shared the same name, all kinds of nicknames were used to create a personal identity. They generally followed the rules I describe above. Often they became proper names in their own right.