I had one fine composer tell me this once:
Using theory is like putting the cart in front of the horse. That is, theory is a collection of patterns caused by music throughout history. These hard and fast "rules" that we have in theory create music of a particular style.
I mean, classical and baroque music follows the rules we teach (no parallel fifths, V goes to I, etc). Romanticism has its own set of rules (by mixture, parallel major/minor keys are the same, avoid V to I and replace it with ii(half diminished 6/5) to I, etc). Even post-tonal music has its own rules, hammered out in the later 20th Century by the composer Milton Babbitt.
That being said, theory can be a useful resource when trying to create a particular type of music. I have a tendency to still resolve dissonances "properly" when approaching anything post-tonal. I still feel using theory to write music can be rewarding, but only at the composer's discretion. And when you do so, ask yourself, why am I doing this here? What will it sound like if I do this here? etc.
In short, theory is a useful tool to create certain styles of music. It is something to know, but not be bound by.