It has been shown and said in multiple episodes that he is capable of performing self-diagnostic and repairs, which implies that his positronic brain possess a copy of his own schematic to serve as reference point, which would include something as vital as the off-switch. That knowledge of himself also allows him to perform modifications of his own body, which he has done in multiple episodes and in the movies.
Though it is to be noted that his knowledge of his own programming seems to be somewhat lacking in certain areas: he was unaware that Dr Soong had a means to recall him from basically anywhere in the galaxy with a simple subspace signal (TNG S04E03 Brothers) nor did he knew about the dream programming until it was inadvertently activated. (TNG S06E16 Birthright).
He is, however, capable to restoring himself to a previous save, as was shown in Contagion (TNG S02E11), when he does so to purge the Iconian program that had infected him and was trying to rewrite him completely.
In Star Trek: Generations, he is shown altering a circuit on his arm to act as a magnetic key, opening access to the secret storage area where Dr Soran hid his solar probes.
We also know that there is a copy of his schematics in the Enterprise's computer, although it is never said how they came to have them, and why it seems that StarFleet Command does not have a copy.
In The Measure of a Man (TNG S02E09), while preparing his arguments for the court that will determine the legal status of Data, Commander Riker access Data's schematic on a screen, and finds the off switch.
[Computer room]
RIKER: Computer, identify Riker, William T. Access code theta alpha two seven three seven, blue, enable.
COMPUTER: Riker, William T, identified. Ready.
RIKER: Access all available technical schematics on Lieutenant Commander Data.
COMPUTER: Working.
(Then up pops 'emergency manual control' and Data's off-switch location is displayed. Riker is fascinated at this new information, then realises the implication)
In Star Trek: Insurrection, Admiral Dougherty requests them from Captain Picard, seeming to imply that StarFleet Command does not have a copy stored at the HQ, which seems a bit strange since Commander Maddox obviously had enough information to try and build a copy of Data's positronic matrix in Measure of a Man.
LAFORGE: Captain. Excuse me. Captain... Captain, Admiral Dougherty's aboard a Son'a ship in sector four four one. He's requesting Data's schematics.
TROI: Is something wrong?
LAFORGE: The message doesn't say.
PICARD: Data should have been back by now. They were only scheduled to observe the Ba'ku village for one week. Geordi, would you set up a secure com-link to the Admiral in the anteroom.
GEORDI: Aye sir.
ADISLO: Captain, Hars Adislo, we met at the Nel Bato Conference last year. Did you ever have a chance to read my paper on thermionic transconductance?
PICARD: Would you excuse me?
[Enterprise-E anteroom]
DOUGHERTY (on viewscreen): He's not acknowledging any Starfleet protocols. Not responding to any of our hails.
PICARD: Have you any idea what precipitated his behaviour?
DOUGHERTY (on viewscreen): None. Now he's holding our people hostage down there.
PICARD: Well the Enterprise could be at your position in two days, Admiral.
DOUGHERTY (on viewscreen): That's probably not a good idea. Your ship hasn't been fitted for this region. There are environmental concerns.
PICARD: What kind of concerns?
DOUGHERTY (on viewscreen): We haven't fully identified the anomalies yet. They're calling this whole area the Briar Patch. It took us a day to reach a location where we could even get a signal to you. Just get me Data's schematics. I'll keep you informed. Dougherty out.
PICARD: His emotion chip?
GEORDI: He didn't take it with him. Send the Admiral Data's schematics.
That may mean only Data knows his full schematic, and they have been downloaded into the Enterprise's computer to serve as help should anything happen to him in the course of duty. Chief Engineer Geordi LaForge seems to be intimately familiar with Data's schematics, fixing him on several occasions and also helping him with tests and modifications on his own body.