How should I store herb butter? I tried just keeping it in a tightly-closed container in the refrigerator, but soon it was moldy. 

I've read this question, which seems to indicate that ordinary butter should keep safely for weeks at fridge-temperatures... But my preparation is hardly ordinary butter. 

My technique is very simple: 200g butter in boiling water and 30g of chopped herb (a mixture of leaves and buds) An hour of boiling, strain the herb with a filter gauze and put the liquid in the refrigerator until the fat solidifies and can be easily separated from the water. (The herb is in my case cannabis.)

Freezing is something I've considered trying, but would this affect the texture, or otherwise damage flavor?
Butter, even a compound butter like this, shouldn't have enough moisture to get moldy easily. I think the issue is that you are clarifying the butter in boiling water, which could be causing pockets of moisture in the finished product. You could try melting the butter in a pan without water, adding the herbs, and then allowing the water based part at the bottom to cook off. Once that has happened, you can strain and chill the butter as usual.