Edit field in contentType B when creating or editing node of contentType A
Try the following:

/**
 * Implements hook_node_presave().
 */
function yourModule_node_presave($node) {
  if ($node-&gt;type == 'your_typeA') {
    yourModule_change_value($node);
  }
}

function yourModule_change_value($node) {
  if (isset($node-&gt;field_node_referenced[LANGUAGE_NONE][0]['target_id'])) {
    //- Get referenced node id
    $referenced_node_id = $node-&gt;field_node_referenced[LANGUAGE_NONE][0]['target_id'];
    //- Load referenced node
    $wrapper = entity_metadata_wrapper('node', $referenced_node_id);
    $wrapper-&gt;field_name-&gt;set(array(
      'value' =&gt; 'test new field value'
    ));
    $wrapper-&gt;save();
  }
}