Python show rig ui if armature is selected
If you add a poll method to your panel class you can use whatever criteria you wish to decide if a panel should be shown.

@classmethod
def poll(cls, context):
    return context.active_object.type == 'ARMATURE' and
        context.active_object.name.startswith('myrig')


When you alter the bone layer visibility it should only effect the one active armature. You can perform tests in the panels draw function to decide if a layer button is shown.

def draw(self, context):
    layout = self.layout
    col = layout.column()

    if context.active_object.name.startswith('myrig'):
        row = col.row()
        row.prop(context.active_object.data, 'layers', index=0, toggle=True, text='head')


Unfortunately I don't think there is an easy way to check if there are bones on a layer, you need to loop through all bones and their layers array.

def used_layers(obj):
    ulayers = [False,]*32
    if obj.type == 'ARMATURE':
        for bone in obj.data.bones:
            for i in range(32):
                if bone.layers[i]:
                    ulayers[i] = True
    return ulayers


Then in the draw method -

def draw(self, context):
    layout = self.layout
    col = layout.column()
    show_layers = used_layers(context.active_object)

    if show_layers[0]:
        row = col.row()
        row.prop(context.active_object.data, 'layers', index=0, toggle=True, text='head')