add login menu with submenu

Here is a barebones example (which I just tested on my site):

add_filter( 'wp_nav_menu_items', 'asv_add_usermenu', 10, 2 );

function asv_add_usermenu( $items, $args ) {
  if (is_user_logged_in() && $args->theme_location == 'primary-menu') {
    $items .= "<li class="sub-menu"><a href="" . wp_logout_url()  . "">Log Out</a></li>";
  } elseif (!is_user_logged_in() && $args->theme_location == 'primary-menu') {
    $items .= "<li class="sub-menu"> <a href="" . wp_login_url() . "">Log In</a></li>";
  }
  return $items;
}

The ‘primary-menu’ text is from this admin page (whatever name the theme registered that menu as). yoursite.com/wp-admin/nav-menus.php It is one of the menu names in grey italics in the top left box.

I gleaned the above from http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items
and codex.wordpress.org/Function_Reference/wp_nav_menu
and I think the ‘primary-menu’ is the only thing environment specific.