I have a notebook connected to a port replicator. I want to use the build-in speakers and microfone and not the external ones. If I boot my notebook in my port replicator Ubuntu changes the devices to external.
- Find your internal speaker
 
pactl list short sinks
0	alsa_output.usb-Generic_USB_Audio_201405280001-00.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	SUSPENDED
1	alsa_output.pci-0000_00_1f.3.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	SUSPENDED
- 
Set your internal speaker as default
pactl set-default-sink <DEVICE>e.g.pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo - 
Add to "Startup Applications" ("Startprogramme" in German)
 
- Open the application "Startup Applications" (Should be preinstalled on Ubuntu)
 - Click on "Add"
 - Give your startup item a name
 - Copy your command from above into the command field.
 - Click on "Save".
 
- Find your internal microfone
 
pactl list short sources
0	alsa_output.usb-Generic_USB_Audio_201405280001-00.analog-stereo.monitormodule-alsa-card.c	s16le 2ch 44100Hz	SUSPENDED
1	alsa_input.usb-Generic_USB_Audio_201405280001-00.iec958-stereo	module-alsa-card.c	s16le 2ch 44100Hz	RUNNING
2	alsa_output.pci-0000_00_1f.3.analog-stereo.monitor	module-alsa-card.c	s16le 2ch 48000Hz	SUSPENDED
3	alsa_input.pci-0000_00_1f.3.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	SUSPENDED
- 
Set your internal speaker as default
pactl set-default-source <DEVICE>e.g.pactl set-default-source alsa_input.pci-0000_00_1f.3.analog-stereo - 
Repeat step 3.
 



@seaniedan - setting default output sink in
/etc/pulse/default.pais more elegant, since this file runs on each system boot anyway.To make it work you have to restart pulseaudio .configs by deleting pulse directory:
rm -r ~/.config/pulseI've found this solution here: https://askubuntu.com/a/1038492
Probably
pulseaudio -kcommand mentioned by @comxd do the same ;)But it's safer to set sink by name instead of its number (which can change), in my example:
set-default-sink alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sinkI also had a problem that my Mic's build-in minijack output was set each time I have plugged my Mic into the USB port. To solve it you can also comment this lines in
/etc/pulse/default.pafile: