The big problem with sugar is that the more you eat it, the more you want it. You should also consider that sugar is not always only in the most obvious foods. That white bread you had for lunch good be the cause of your mid-day craving for a candy bar. The pasta you have for dinner could also be to blame. Every time you give into a craving, you contribute to the habit. Caving will only temporarily silence your sugar beast. It will always want more.
There isn't one single solution to this problem and your first step is being aware of its sabotaging effects. There may be times when you think you want to eat something sweet but in actuality you don't really want it. How many times have you indulged in sweets only to eat so much that you stop enjoying it? Chances are you could cut back with just a few tastes until you are satisfied. If you tell yourself "no, you can never have sugar" then you will only want sugar. You have to change your mindset to "I can have sugar, but I don't want it right now" once you allow yourself to have it you are much less likely to want it.
Each time that you start a new diet you are excited and dedicated to losing weight. You're going to be strict this time and make it through to the finish line. Then, as soon as it starts and you're momentum is going, you want sugar right this second! You cave and then get derailed. And the cycle begins. Next time, instead of feeling guilty for an occasional small treat, learn to savor the experience and you will find that just a few bites or even half of what you normally would want is all you need.
Typically cravings only last for a couple of minutes so all you have to do is wait it out. Sometimes you will have a quick craving right after eating. You should always give yourself 15 minutes before you eat anything more after a meal because it takes that long for your body to feel full. Every craving that you learn to ignore you will become stronger, instead of caving every time you will learn that they lessen over time.
Learn to talk yourself or distract yourself out of a craving. Every time you want something sweet just tell yourself "I realize that this is my body's reaction to stress or what I just ate and it will pass, I don't really want something sweet" and reward yourself everyday for not eating a sugary treat. You could give yourself a dollar a day and use that money to treat yourself with a new outfit or a pedicure at the end of the month. Save your sweet indulgences to no more than once a week and you will find that you are less likely to have cravings.