In-universe, the Doctor has always kept his real name a secret, for reasons that have never been fully explained. In "Forest of the Dead" he states there is only one reason he would tell anyone his real name, but these circumstances have never been revealed. It was teased in "The Wedding of River Song" that marriage is that circumstance, however it turns out this is not the case. River Song doesn't learn his name until later, and she indicates that she had to make the Doctor tell her per "The Name of the Doctor" though the Doctor likely told her voluntarily knowing that she had to know it in order to use it to establish her credentials on their first meeting (in his chronology) in "Silence in the Library"; we do not know when this occurred.
We also know the Doctor's real name exists in at least one print source as per "Journey to the Centre of the TARDIS" when Clara reads it (but she soon forgets the name when the timeline resets). Only one other companion is known to have knowledge of the Doctor's real name, and that's Samantha Jones per the novel "Vanderdeken's Children" (novel).
In "The Time of the Doctor", after hints dating back to "The Wedding of River Song", it's indicated that there is now another reason why the Doctor's true name must be kept secret, as uttering it will allow the Time Lords to return to the universe at Trenzalore, reigniting the Time War.
Behind the scenes, it was decided early on (how early on is a matter of debate) that the Doctor's real name should be left a mystery. After more than 50 years keeping the name a secret (the occasional tease notwithstanding) has become part of the tradition of the series.