How do I make this electronics system of circuits and batteries work?
where Battery #2 will connect with pins (like wireless earbuds) to Battery #1 so Battery #2 can get charged (from Battery #1).

WARNING:
It is VERY unwise and also dangerous to directly connect two batteries together in order to try to charge battery 1 from battery 2. If battery 1 is relatively discharged and battery 2 is relatively charged VERY high currents can flow between the two batteries.
Depending on the LiIon batteries used this could cause fire and/or  damage to the batteries.
You could add a resistor in the circuit between batteries - but this will waste energy and  needs to be sized for the worst case relative charge situation.
An  acceptable solution is to add the circuitry from a battery bank that will accept 3 to 4.2 V in and provide battery charging out. Because of the way battery banks usually work not all will operate with 3V to 4.2V in.
What will work - and it adds complexity and inefficiency is to use TWO battery bank circuits. Battery 2 inputs to the battery terminals on PB2 and outputs 5VDC. PB2 5VDC out connects to 5vDC IN on PB1 and charges battery one connected to PB1 battery terminals.
__________________

My question is, how do I make it so that when Battery #2 is disconnected from Battery #1, Battery #2 and Circuit #2 are connected.   ....

You can almost do this with manual switching, and do it exactly with a relay or simple circuitry.
In both cases a 4 pin connector is used  between B1, L1 &amp; B2, L2.
2 wires connect the batteries via a charging arrangement - see above.
2 wires are used to connect load 1 to load 2.
Manual:
If you don't mind having to manually switch B2-L2 when the modules are disconnected then this is an easy and low cost solution.
Provide a switch S1 between B1 - L1 and another between B2-L2.
When the connection is made charging occurs from B2 to B1 and L1 is connected to L2.
If S2 is operated both L1 &amp; L2 are powered by B2
(If S1 is operated then both loads are powered by B1 but that is not on your requirement list).
When the connector is disconnected then B1-L1 is controlled by S1 and B2-L2 is controlled by S2.
Automatic.
To fully meet your description, add 2 contacts to the connector.
A relay in both modules can be operated via the 2 extra connections when the modules are connected.  The relays can connect or disconnect Bx to Lx as required when the modules are separated.
A simple electronic circuit (one or two transistors and a few resistors on each module) could replace the relays.
I could draw the related circuit, but I suggest that you look at the above descriptions and draw a circuit that matches. Ask if too hard after giving it a try.
A circuit with a 2 pin connector may be possible but with extra circuit complexity.
_________________________
Below is an example only circuit that meets what I understand your requirement to be.  S2 operates both loads when the two modules are joined and load2 only when separated. Load 1 is automatically powered on separation.
When plugged together:

B2 charges B1 via a suitable charging circuit.

Switch 2 operates Load 2 and Load 1 from Battery 2.

Q3 is turned on via R3 and turns Q1 off.


When unplugged:

Switch 2 operates load 2 from battery two

Q1 is turned on by R7 so Load 1 is powered by Battery 1 .


Three wires is possible with a little more complexity.
Two wires would need &quot;signalling&quot; over the charging circuit and is possible but non-trivial. Use of eg optocoupled signalling as well as the two power leads would allow two wires plus the opto link.
In this mode S2 controls L1 &amp; L2 powered from B2. | When separated S1 controls L1 from B1 and L2 is on from B2.



simulate this circuit &ndash; Schematic created using CircuitLab
In the above diagram charge direction is left to right.
Assume source battery is of higher mAh than target battery.
R7 ~~= V/Ib
Ib ~= Ichg/Beta_Q1*2
Say Beta = 100 (higher available).
Say Ichg = 150 mA max.
V_R7 ~= 2.5V
R7 ~= 2.5/(0.150/100 x 2) ~~= 1K
Change Q1 to a suitably low Rdson MOSFET for much lower standby current.
R3 maybe 33k
R6 maybe 220k
MOSFETS allow much higher resistor values ane lower losses via resistor strings.
If using bipolars then eg BC327-40 / BC807-40 have higher beta so allow larger resistors.
__________________
This addresses the various discussions. I have not gone over it in utter detail compared to spec as the spec is somewhat fluid - and a boost converter is still needed for battery-battery charging BUT it shows how one side can auto turn on when disconnected and how both sides are controlled by one switch when connected.
Click image for larger version