Assuming the head socket is a socket you added to the SkeletalMesh and named it “HeadSocket” something like this should work on a character constructor.
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Camera Boom"));
SpringArm->SetupAttachment(GetMesh(), FName("HeadSocket"));