Which post does a taxonomy term belongs to?

You could do it using the term_link filter.
Something roughly as follows:

function my_term_link($termlink, $term, $taxonomy) {
   global $post;
   if ($taxonomy == 'my-custom-taxonomy') {
      return get_permalink( $post->ID ) . '#' . $term->term_id;
   }
}

while ( $programtype->have_posts() ) : $programtype->the_post();
   $terms = get_the_terms( $post->ID, 'my-custom-taxonomy' );
   add_filter('term_link', 'my_term_link', 10, 3);
   foreach ($terms as $term) {
      $link = get_term_link( $term, 'my-custom-taxonomy' );
      // Use link here
   }
   remove_filter('term_link', 'my_term_link', 10, 3);
endwhile;