Default Warning
The battery indicator in the menu bar will turn red when the battery is low. There will also be a critical low power warning when the computer needs to emergency shut down.
See Apple's About Mac notebook batteries page, in particular this section:
The low battery warning doesn't display
If you don't receive a warning when your battery has a low charge, generally reported at or under 15%, it may be because the battery menu bar icon is disabled. Follow these steps to enable the battery status menu item:
- Open System Preferences.
- Click Energy Saver.
- Enable the "Show battery status in menu bar" check box to display the battery status menu item.
Note: Portables using OS X Mavericks v10.9 or later display the low battery warning when the battery has approximately 10 minutes of power remaining. Earlier versions or OS X instead report it at 15% or less.
Third Party: Power Manager
Software such as Power Manager can be used to trigger scripts, sounds, and actions when the battery level drops:
More advanced abilities such as stopping music from playing and integrating the warning into your workflows is possible. Battery levels and changes are exposed through Power Manager's AppleScript interface.
Disclosure: I am an engineer who works on Power Manager. So, feel free to ask technical questions about the product.