The use of monikers such as M and Q is, IMO, more to do with tradition and traditional anonymity than secrecy.
(See my answer to another Bond question for more on this.)
You can see colleagues mingling socially (the opening scenes of Licence to Kill come to mind) and Bond pops up to M's flat on a couple of occasions.
M, Q, and Miss Moneypenny are all invited to Bond's wedding in OHMSS, and the scene, IIRC, begins with "Your Royal Highnesses".
I'd say that this out-of-office mingling isn't done without knowledge of their real names.
Furthermore, M is often a well known political appointee just like the head of the real MI6.
The first M was a Sir Miles Messervy.
James Bond too has an alias within MI6—he is 007.
I don't think/consider Moneypenny to be a codename.
(The question of why Bond does not use an alias outside MI6 is a good one.
While the correct answer to this is, of course, "because it's the movies", there is a rather feeble in-universe explanation for this.
James Bond's front when he is out on the job is that he is an employee of Universal Exports, a shell company created by MI6.
Presumably, this also explains his frequent travels abroad and general worldliness.
However, when this alias does not suit his purposes, he happily takes on other personae such as that of Sir Hilary Bray (OHMSS), James St. John Smythe (aVtaK), et al.)
movies.stackexchange.com/users/3650/coleopterist
While one would expect a "secret agent" to always use a cover, James Bond is not a secret agent:
Intelligence organizations have complete and detailed files on him.
Most bad guys know who he is, what kind of firearm he carries, and how he likes his drinks.
The bad guy usually tries to kill Bond as he arrives in town.
When he investigates someone, he almost always meets them socially first—a gentlemanly introduction perhaps to learn the other side of their persona, or gather information useful to plot later espionage.
But they always know he is 007 James Bond.
Apparently his actions are reported worldwide in mass media, like when he was "killed" in
You Only Live Twice .
If he is any kind of secret agent at all, he is an "open secret agent".
movies.stackexchange.com/users/4739/wallyk
Bond does use an alias in several of the Bond films as detailed in this article ; Movie AliasFrom Russia with Love David SomersetYou Only Live Twice Mr. FisherOn Her Majesty's Secret Service Sir Hilary BrayDiamonds Are Forever
Peter FranksDiamonds Are Forever Mr. JonesDiamonds Are Forever Klaus HergescheimerDiamonds Are Forever Burt SaxbyThe Man With The Golden Gun Fransisco ScaramangaThe Spy Who Loved Me Robert SterlingA View to a Kill James St. John SmytheA View to a Kill James StockThe Living Daylights
Jerzy BondovThe World Is Not Enough Dr. Mikhal ArkovDie
Another Day Van BierkCasino Royale Arlington Beech
movies.stackexchange.com/users/4888/Graeme Hunter
I'm going to throw out my own thoughts.
Wikipedia states that In the first draft of Casino Royale he decided to use the name James Secretan as Bond's cover name while on missions.
This approach was clearly discarded and for several books he keeps the name Bond.
If memory serves however his identity as James Bond and 007 are kept separate so for the most part only a few key members of the secret service are aware of his position within the organisation.
In the early films this trend is continued although he introduces himself as "Bond, James Bond
" it's very rare that villains are aware of his job.
After Sean Connery's line in the Doctor No (1962) the character was never going to introduce himself any other way!
The franchise is the "James Bond" series.
To have the main character introducing himself using a variety of names in each film (with different actors) would be extremely confusing to first time and casual viewers and watchers.
In order to keep the films simple and avoid confusing viewers this approach of keeping his position in MI6 secret rather than his name has been maintained.
In short - James Bond uses his real name because the filmmakers want to maintain the famous name of the character on screen.
His safety comes from the fact that the people he encounters on his adventures are unaware (except for a few exceptional villains) that he is 007.
movies.stackexchange.com/users/574/Liath
Interestingly enough, there are other indicators that suggest that "James Bond" becomes the name of the new agent designated for the 007 slot, so that would logically provide the alias from his real identity...and anonymity for a few missions until an enemy agency picks up on the name.
However, given tech these days, a permanent alias wouldn't do much good anyway, since cameras and databases everywhere are going to verify who he is at light speed.
The trick is to just not let people know where you ARE, and that's always been his style, and something that right pisses off his employers regularly.
He just doesn't go through the trouble of the ID when he's expected.
Remember, as the reboot proved, everyone knows his name from the start...
but, quizzically, he's also a new agent in the role, showing the two kills he needed for 00 status.
M also says "orphans make the best agents," which hints at more than one orphaned naval intelligence officer donning the role.
They're very cagey about the whole thing, but the clues are there.
movies.stackexchange.com/users/9302/Will
In the James Bond universe most characters go by a code name M, Q, the various 00s, In Skyfall Silva is a made up name.  Others such as Tanner, Robinson and Moneypenny, Trevelyan we're not so sure but we've got no reason to believe they're real.  However Bond uses his own name - we've even seen the grave of his parents to confirm this.  Why does Bond use his real name and (as far as we know) no one else does?
Why does James Bond use his real name?
movies.stackexchange.com
<james-bond>
movies.stackexchange.com/questions/11384
movies.stackexchange.com/users/574/Liath
James Bond uses his real name because the filmakers want to maintain the famous name of the character on screen. In short - James Bond uses his real name because the filmmakers want to maintain the famous name of the character on screen. 
James Bond is not a secret agent. Bad guys know who he is, what kind of firearm he carries, and how he likes his drinks. When he investigates someone, he almost always meets them socially first. If he is any kind of secret agent at all, he is an "open secret agent" if not a "secret agent" at all. He always meets people socially first, perhaps to learn the other side of their persona.In short - James Bond uses his real name because the filmmakers want to maintain the famous name of the character on screen. 