Where does energy go when not enough voltage is applied to charge a battery?
In general, to charge a battery, you need to apply a slightly higher voltage to the battery than the current battery's voltage.

So if the battery is 1.2 V, you will need to apply more than 1.2 V. For example if you would apply 1.3 V then that would make current flow from your 1.3 V source into the 1.2 V battery. Since the current flows into the battery that means that also energy is flowing into the battery.

It is important to limit that charging current so applying 2 V without any series resistance to limit the current might cause the charging current to become too high and damage the battery and/or DC motor. It depends on the situation though, if your DC motor is small and can only supply say 1 A but your battery is very large and can handle a 10 A charging current, then obviously there would be no issue.

If you try to charge with 1.2 V then almost no current would flow as the voltages of the source (your DC motor) and battery are equal.

If you would apply no power to that DC motor, obviously the 1.2 V of the battery would make it spin. The battery would be discharged.