I've mostly heard it as a standalone exclamation, usually with a 耶 or comparable word attached.
真是伤脑筋!
伤脑筋耶!
But you can use it in other ways too. Here, have some examples (from my dictionaries, so you can trust them)
与刁钻古怪的人做朋友,当然是大伤脑筋的事。(adj)
有些广告词读起来让人莫名其妙,真伤脑筋。(exclamation)
人总是要犯错误、受挫折、伤脑筋的,不过决不能停滞不前;应该完成的任务,即使为它牺牲生命,也要完成。(adj)