Dealing with that last year was a pain. My old fireplace had a few bricks that were shaky. I mixed up some refractory mortar, the kind that handles heat, and packed it in deep behind the loose one. Used a piece of wood to really wedge it in place tight. Let it cure for a full day before I even thought about a fire. It's held solid through a whole winter now.