Well, the answer is right at the end of the story, and a close reading of the story itself is the best way to discover it. If you haven't read the story yet, I suggest you do; it's one of O. Henry's shorter stories, and so is a very quick read. I provided a link to the story below.
In this story, a young woman named Johnsy gets sick with pneumonia, and out her window is a vine. On that vine, the leaves keeps falling off. Pretty soon, there is just one leaf left. Johnsy declares that "When the last one falls I must go, too," meaning, she will die when the last leaf falls of the window. Her roommate, Sue, tells her that she is silly, but deep down is disturbed by Johnsy's morbid declaration. She watches the last leaf all day, paranoid. She goes downstairs and tells the old man that lives there, Behrman, what Johnsy had said. He scoffs such sentimentality, but comes up to pose for Sue (Sue's an artist), and he too seems disturbed, and keeps a close eye on the leaf.
Well, the next morning the leaf is still there, and then the next, and Johnsy gets much, much better and eventually recovers. But once she does recover, Sue informs her of the following:
"Mr. Behrman died of pneumonia to-day in the hospital. He was ill only two days...they found...a ladder that had been dragged from its place, and some scattered brushes, and a palette with green and yellow colors mixed on it, and—look out the window, dear, at the last ivy leaf on the wall. Didn't you wonder why it never fluttered or moved when the wind blew? Ah, darling, it's Behrman's masterpiece—he painted it there the night that the last leaf fell.”
So, old Behrman had gone out and painted a leaf on the wall where the real one had fallen in the night, so that Johnsy would think it was still there. In doing so, he caught cold and contracted pneumonia and died. So, that is the surprise ending. Once again, please read the story; it is a very good one. I hope that helps! Good luck!
The surprise at the end of O. Henry's "The Last Leaf" is very simply that the leaf was not real but had been painted on the wall. The reader is thoroughly fooled by being led to believe that the last leaf is real and that somehow it has clung to life throughout a violent storm. This image is effective because we have all seen similar sights in the wintertime. Sometimes, amazingly, a few green leaves will still cling to the branch of a tree after all the other deciduous trees in the region are completely bare. The green leaves seem to be surviving by sheer willpower, refusing to die. The sick girl called Johnsy identifies with this brave little leaf and feels inspired to cling to life herself. The doctor has advised her friend Sue that Johnsy has a good chance of recovery if only she will muster the will to do so. It appears at first that it is the leaf itself which has saved her, but then the reader learns that the crusty old painter called Old Berhman has sacrificed his own life by going out in the stormy night to paint that leaf so realistically that Johnsy naturally assumes it is real. But the actual surprise comes to the reader with the realization that the last leaf is only a painted leaf. This is one of O. Henry's best loved stories because there is a serious issue involved and a serious sacrifice is made. It is sentimental and romantic but still moving because it is just barely credible.