Sherlock himself says in the last paragraph, last line of the story,
"....I am no doubt indirectly responsible for Dr. Grimesby Roylett's death, and I cannot say that it is likely to weigh very heavily upon my conscience."
He feels this way because after observing the room in which Helen Stoner was sleeping, he noticed that whatever danger there was in the room did not enter through a window or a door. Therefore, the only other entry was the ventilator which connected Dr. Roylett's room with Helen's. The bell rope, which was located right next to the bed, did not have any functional use. The bed was clamped to the floor so that it could not be moved. Therefore, Sherlock surmised that the bell rope had to be bridge for something coming through the ventilator.
Sherlock realized that it could be a snake because he knew that Dr. Roylett was "furnished with a supply of creatures from India." Dr. Royett's Eastern training made Sherlock believe that he would know of a poison that was undetectable by Western standards. Sherlock realized that the milk he found in Dr. Roylett's room and the whistle and leash were all part of the training Dr. Roylett gave the snake. He had to recall the snake before morning came and kept it in the safe in his room. He couldn't be sure that the snake would bite the occupant of the bed, but if he put the snake through the ventilator enough times, sooner or later someone would be bitten.
Sherlock stayed in the room at night. When he heard the snake hiss, he attacked it. That made the snake angry and drove it back into Dr. Roylett's room. Since Dr. Roylett was the first person the snake could attack, it attacked and killed him quickly with its poison.
Indirectly, Sherlock was responsible for Dr. Roylett's death, but Dr. Roylett is also responsible for his own death in the fact that he brought the snake into the house and trained it to return to him.