Bottom line - learning usually isn't fun. But if you want to be able to play fun stuff later on, you need to buckle down and practice now.
I've always had the same problem. I'll sit down and start practicing some song or riff, but before long I'll be goofing around and improvising.
Your teacher is right. Try setting up times to learn scales, songs, etc, but leave time for improv too.