Running ajax callbacks on custom composite field
You can not modify the $form in the ajax callback. The option for the element out_serial should be set inside form build not in ajax callback. Try with following approach:

// Inside your form build or alter function.
$form['elements']['test']['#element'] = array(
  'out_part' =&gt; array(
    '#type' =&gt; 'select',
    '#id' =&gt; 'out_part',
    '#options' =&gt; array(
      '80002192'=&gt;'80002192',
      '80002191'=&gt;'80002191'
    ),
    '#ajax' =&gt; array(
      'event' =&gt; 'change',
      'wrapper' =&gt; 'serialNumber_wrapper',
      'callback'=&gt; 'populateOutSerialNumbers',
      'method'=&gt; 'replace'
      )
    ),
  'out_serial' =&gt; array(
    '#type' =&gt; 'select',
    '#id' =&gt; 'out_serial',
    '#validated' =&gt; TRUE,
    '#attributes' =&gt; [
        'id' =&gt; ['serialNumber_wrapper'],
      ],
    )
);         

// Set value here as when you return the element in ajax callback.
// the form will come here again for rebuild with $form_state having filled values.
if (!empty($form_state-&gt;getValue('test'))) {
  $partNumber = $form_state-&gt;getValue('test')[1]['out_part'];
  $partNumber = isset($partNumber) ? $partNumber : 'Onboard';

  // Update the $result with dynamic database query results with respect to selected out_part
  Drupal\Core\Database\Database::setActiveConnection('***');  
  $db = Drupal\Core\Database\Database::getConnection();
  $query = $db-&gt;query("select distinct T1.serialnumber from assets T1 where T1.dbid &lt;&gt; 0 and (T1.manufacturerpartno = :partNumber)", [':partNumber' =&gt; $partNumber]);
  $result = $query-&gt;fetchAllKeyed(0,0);

  $form['elements']['test']['#element']['out_serial']['#options'] = $result;

  db_set_active();
}
// End of your build or form alter function.

/**
 * Ajax callback of out_part element.
 */
function populateOutSerialNumbers($form, $form_state){
  return $form['elements']['test']['#element']['out_serial'];
}