Ok, first of all, panicking is the worst thing to do, stay calm and we'll get him/her taken care of.
Male or female?
How old is your dragon?
How long have you had your dragon?
Was your dragon a rescue?
Do you use UVB? Please be specific (Coil, compact, flourescant, etc.)
Do you use a heat rock or undertank heater?
Do you give your beardie baths? If so, how often?
What do you feed your dragon?
Have you gotten a fecal done?
What substrate do you use?
How much and often do you feed him?
It sort of sounds to me like parasites, so a fecal is a very good idea. Does his...well...poop, smell bad? If so, he probably has parasites! Has he been eating?
Uh-Oh that sounds like parasites I wouldn't mess around he sounds stressed if you can his next poop get a Baggy and collect some take it to your vet and ask them to run a fecal for parasites, fecals usually cost $12-$18 and if the dragon has parasites most likely the vet would give you Panacur i think Panacur is the safest to use unless you treat it herbally. But I really would get his poop to a vet ASAP and take him with you so they can get a weight to properly dose the meds if it's needed.