It may just be that he is constipated or has a bad tooth. A dog with a tooth issue will avoid eating but othewise be ok. Check your dog's mouth for tartar on the teeth, possibly red gums, darkened teeth, broken teeth or something caught between the teeth or gums. If you find something stuck, try and remove it. If it is bad teeth, you can give him Buffered aspirin can be given to a dog with a dosage of up to 5 mg per pound every 12 hours. Keep in mind that a dog's body does not metabolize aspirin in the same way as a human and thus should not be given more than a day or two without contacting your Vet. At 7 months though, he shouldn't have too many issues, though if his molars are coming in they might be bothering him.
Constipation can cause a dog to stop eating. If your dog is experiencing constipation on a regular basis you should add roughage to his diet such as canned pumpkin (not pie filling kind) or Metamucil. A spoon full of pumpkin on the dog's food should keep his bowels hydrated and his feces soft enough to pass. A spoon of mineral oil on his food can also be used but should not be used all the time.
Now since your dog is not eating, there are two methods I use for young puppies, which may work on your dog. I first try lubricating a rectal thermometer and take the puppies temperature. This frequently stimulates the puppy into going. If this fails and you have a nasal bulb syringe (aspirator), you can put warm water in it and gently squeeze a small amount into the rectum and see if this doesn't help.
You can use a children's glycerin suppository depending on the size of your dog but the other methods are what I recommend you try first.
IMPORTANT NOTE If your dog ate a non-food item, bone or rawhide recently or if your dog is experiencing other symptoms such as vomiting, not eating or drinking, severe abdominal pain, the dog needs to see a vet. The above signs could indicate an intestinal obstruction, which you can read about here:
if your dog becomes dehydrated. You can tell by pulling up the skin between his shoulder blades and seeing if it flows back down normally. If it stays tented or is slow to return to normal, your dog is dehydrated and needs fluids immediately and should see a vet as soon as possible.
If gums and tongue become pale and not a normal pink color or the rectal temperature is over 103F (101-102F is normal) or your dog becomes lethargic and non-responsive, your dog should also see a vet as soon as possible.
You can try some pepcid in case he has an upset stomach. Read about Pepcid dosages and usage information here: http://www.petplace.com/drug-library/famotidine-pepcid/page1.aspx
Give him a drop of pancake syrup to keep his glucose levels up if he isn't eating. If there is a female in heat around, that can also cause a male to get keyed up and stop eating as well. Try tempting him with some boiled chicken and rice after using some pepcid. If he does fine with that, gradually shift him back to dog food. If he still doesn't eat, then you mght want to have him seen by your vet to check for ingestion of a foreign object.
I hope you find this information helpful.