A properly maintained hot compost pile will kill weed seeds, as well as many other pathogens, so you can compost weeds without having to worry about them popping up in your garden beds.
Why should you not compost weeds?
The heat from your compost should damage and destroy roots and seeds so that your weeds will not propagate from the compost. However, for most of us, it isn’t as easy as that. Unfortunately, most home compost bins do not get hot enough to destroy all seeds and roots.
What do you do with pulled weeds?
When you pull or till young weeds, leave them where you chop them and let the sun dry them out, then use them as mulch. Throw mature weeds on a hot compost pile where they should cook at 200 degrees or higher for several weeks to ensure the seeds are killed.