One of the most important parts about a comedy routine is the beginning. Your only goal at the start is to get the audience to like you. You can do this by telling a clever joke, telling a personal story about yourself or just riffing with the crowd. No matter how you do it, this is a huge step to having a successful set. The same is true for the ending. As you leave the stage, the audience needs to like you. By ending on a strong joke or segment, that most recent memory tends to override their other perceptions of you during the performance.
While it sounds cliche, your only true success will come when you tell jokes you believe are funny. Over time, the audience's reactions will shape your sense of comedy to be more attuned to what's naturally funny. If you only tell what you think should be funny, you won't accurately learn how to adjust your sense of humor. Almost all the best comedians have a very distinct style and voice, which is the result of fine-tuning their sensibilities over years of experience.
By noticing naturally occurring callbacks in your set, you can create a tighter performance. These connections not only make you look like a smart, clever person, but your audience will remember your performance better when one joke reminds them of another joke. If possible, try to notice themes throughout your set. A theme is a recurring idea, such as "city life is bad," "women are better than men," and so on. By connecting two segments (or your entire routine) with a theme, you make the audience think, as well as laugh, about the issues you raised.
Watch comedians as often, if not more often, than you perform yourself. By watching others, you'll begin to notice when they make mistakes or when they make key moves to reach success. This knowledge will help you create a better set, but also help you differentiate yourself from the crowd. Also, many comedians video record their sets to watch later. Watching yourself may be awkward, but it helps you know how you feel onstage translated from an audience's perspective.