People say this when something tastes good, or when it looks or smells like it's going to taste good.
There's also the word "yummy". Both "Yum!" and "Yummy!" sound like something that a young child would say, but "Yummy!" sounds more childish than "Yum". A more adult-sounding expression to say when something tastes good is:
That's really good.
Or when you smell something that seems like it's going to taste good:
That smells great.
When you see it: