Sofia Vergara is thinking about undergoing hypnosis to cure her sweet tooth.

The 'Modern Family' actress admits she only works out so she can eat cake on a regular basis and claims she is seriously considering going to a specialist to help her get over her obsession with candy.

The 42-year-old star told the November issue of Shape magazine: ''I heard about someone in L.A. who got hypnotised so they wouldn't eat candy. I'm seriously looking into that because I'm obsessed.''

The brunette beauty, who is dating 'Magic Mike' star Joe Manganiello, ''has always been very happy'' with her figure, but credits her co-star Julie Bowen for inspiring her to get fit and healthy two years ago.

She said: ''I hit 40 and I started seeing a softness everywhere on my body ... I knew it was time to do something, so I did.

''Being around Julie and seeing how motivated she is ... I started to think more about it.''

She added: ''When I do indulge, I exercise a bit harder the next day. My workout motto is really simple: No pain, no cake!''

Sofia is unable to run or do traditional squats because of her ''bad knees'' so she trains with a Pilates-like machine called the Megaformer.

She added: ''I don't love it at all, but I love how my body's changing.

''My body is looking better than it used to, but I wish I had worked out more when I was younger and taken it as seriously as I do now. My niece is 21 and she loves exercising, and I tell her, 'Keep doing it so you don't have to go crazy with it when you're my age!' ''