Balancing is usually done with a PID (Proportional Integral Differential) control loop. The input is how far off vertical you are. The output is the direction and PWM value for the motor controller. Any H-Bridge motor controller (like the L298N) that can handle the voltage and current requirements of the motor will work.
There is a PID library that can help with the coding: http://playground.arduino.cc/Code/PIDLibrary
The hard part is usually "Tuning" the PID constants. You need the control to react quickly but not overshoot. There is an PIDAutotune library that may help with that: http://playground.arduino.cc/Code/PIDAutotuneLibrary