Inserting jQuery corresponding to a certain element ID
You can add a javascript file from a module or a theme, whatever is most appropriate. For scripts that should be loaded on (nearly) all pages, just add a line to the .info file of your module or theme:

scripts[] = somescript.js


For scripts that you only want to load in certain occasions, use the drupal_add_js module. See Managing JavaScript in Drupal 7 for details.

That said, there are a lot of modules out there for drop down menus, so that may even be easier. Check Comparison of various drop down menus for instance, or simply search drupal.org or drupalmodules.com.