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!