From Best to Worst:
Mechanical failure - An unsecured part or wiring or structural component might intermittently resonate with vibrations caused by nearby fans or motors - these can be fixed by firmly securing or padding the moving objects with electrical tape or zipties or rubber spacers or whatever, although care should be taken not to encase or insulate components which require airflow for cooling.
Electrical/Mechanical failure - Loose inductor coils can sometimes oscillate and "whine" across certain audible frequencies - these are often easily fixed with a touch of epoxy or potting agent, although care must be taken not to bend or deform the wires because this will change the specific electrical parameters/performances of the component.
Electrical failure - Bad electrolytic caps can produce high-frequency "whining", "cracking", or "popping" when arcs between internal plates exceed rated puncture voltages, almost always entirely inaudible unless listening carefully with a stethoscope - such caps are already derated and already doomed to fail and leak and burn, they should always be replaced immediately (preferably with higher-rated caps).
Electrical failure - Oscillators, Voltage Regulators, and Power Regulators are highly sensitive and finicky things when operated at (or beyond) their peak rated thresholds, VRMs on overclocked (or factory-overclocked) motherboards and GPU cards are especially notorious for "whining" when running heavy loads - combined variation within individual VRM component tolerances sometimes collectively produce excessively "noisy" or "whiny" circuits which individual motherboard/card manufacturers sometimes deem "acceptable" or sometimes deem "unacceptable" for RMA purposes.
Try updating your BIOS and firmware, this might actually correct this issue if you're very lucky.
Try reseating all user-serviceable components - things like like the battery, memory, drive(s), and any movable panels or flaps or switches - to confirm these parts are all properly secured and cannot vibrate. It probably wouldn't hurt to vacuum out the vents and such to ensure proper airflow.
Try running the machine at stock settings - meaning don't overclock or overspec or overstrain anything - while monitoring temps - a dead or dying fan could cause overheat which could then cause electrical failures which could manifest in things like "whine".
Try to isolate exactly what and where and when this whine occurs. Display panel, drives, motherboard, etc? From your description, I'm guessing it's something related to the power-regulating circuitry inside the battery or the battery-charging module inside the laptop, possibly an intermittent failure caused by thermal stress (ie, electronics seem to fail after they get too hot) - I'd try to determine if this whine can be reproduced, if it's related to the % charge level of the battery, if it's related to the battery (and adjacent parts of the laptop) getting excessively hot, if the whine and/or excessive overheating occurs when the battery is simultaneously charging and discharging (flat charge, AC power, running heavy processing load).
"All opinions are not equal. Some are a very great deal more robust, sophisticated and well supported in logic and argument than others." - Douglas Adams
[/Korth]