This is how Joomla user profile plugins does
// Sanitize the date
$data['profile']['dob'] = $this->_date;
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__user_profiles'))
->where($db->quoteName('user_id') . ' = ' . (int) $userId)
->where($db->quoteName('profile_key') . ' LIKE ' . $db->quote('profile.%'));
$db->setQuery($query);
$db->execute();
$tuples = array();
$order = 1;
foreach ($data['profile'] as $k => $v)
{
$tuples[] = '(' . $userId . ', ' . $db->quote('profile.' . $k) . ', ' . $db->quote(json_encode($v)) . ', ' . $order++ . ')';
}
$db->setQuery('INSERT INTO #__user_profiles VALUES ' . implode(', ', $tuples));
$db->execute();
You can get reference from Root => plugins => user => profile => profile.php in onUserAfterSave function.