I have seen a lot of older posts about the differences between the particles に and で. But I am surprised that neither pair in this question seems to have been asked before.
「Xで」implies X is the reason for the confusion, puzzlement, or troubling. This seems an easy enough criterion. I feel roughly 60% confident about picking one over the other. But there are still cases where I am not sure about the particle.
For example, why doesn't 「人間関係に悩む」work? This may not be the best example, because I probably wouldn't make a mistake here, but I can't articulate the reason for で over に either. How about this 「セックスレスで悩む主婦」?