How to set attribute for checkbox field
I'd recommend you do this via a form alter.  But that aside, the reason your code doesn't work is that you're not doing your comparison correctly.

if ($element['#attributes']['id'] = 'edit-profile-carer-field-profile-active-und') {


Should be:

if ($element['#attributes']['id'] == 'edit-profile-carer-field-profile-active-und') {


And you're also not setting the attribute correctly.  So the final function should be:

function mytheme_checkbox($variables) {
  $element = $variables ['element'];
  $element ['#attributes']['type'] = 'checkbox';
  element_set_attributes($element, array('id', 'name', '#return_value' =&gt; 'value'));

  // Unchecked checkbox has #value of integer 0.
  if (!empty($element ['#checked'])) {
    $element ['#attributes']['checked'] = 'checked';
  }

  //*******Added 3 lines below*******
  if ($element['#attributes']['id'] == 'edit-profile-carer-field-profile-active-und') {
      $element['#attributes']['data-toggle'] = 'toggle';
  }

  _form_set_class($element, array('form-checkbox'));

  return '&lt;input' . drupal_attributes($element ['#attributes']) . ' /&gt;';
}