This is a bit of an undocumented feature, but it works like this.
In your extension, add a class variable called
$required_by, with an array of values:
$required_by = array('module');
('module' is actually the only acceptable array value here, as neither plugins nor accessories have installation routines, which are needed for this to work.)
Note that this does not automatically install (or later, uninstall) your extension. It just makes it clear that you can't install one without the other.
So your module's
install() method must also install your extension (basically, everything you'd normally have in your extension's
activate_extension() method). Likewise, your module's
uninstall() method must contain everything your extension's
disable_extension() method would normally have.
(These methods in your extension in this case should just
Have a look at the bundled Safecracker package for a good example.