fb_facebook_user()

fb.module provides a method, fb_facebook_user(), which returns the user's ID on facebook. It will return a positive integer if a) the user is logged into facebook and b) has authorized your application. In other words, if they are connected this function returns their ID.

if ($fbu = fb_facebook_user()) {
  // The user is connected to facebook and $fbu is their ID.
}
else {
  // The user is ether not logged into facebook or has not authorized the application.
}

fb_get_fbu()

fb.module also provides fb_get_fbu(), which will tell you whether a local drupal account is connected to a facebook account. This will return a facebook user id regardless of whether the user is currently logged into drupal of facebook.

if ($fbu = fb_get_fbu(42)) {
  // The local user with uid == 42 is mapped to a facebook ID ($fbu).
}
else {
  // The local user with uid == 42 is not connected to facebook.
}