What are the rules for pronunciation of the ie sound in German?
In German, the single letter i may be spoken as a short sound as in mit, or as a long sound as in Stil. You even have both versions in the word Pazifik (the first i is pronounced long, the second is short, without any obvious indication for that).
It is supposed to be a general rule, that ie is always spoken as a long sound, as you noticed in Bier. The examples of vierzehn and vierzig are the only counter examples i know.
Conversely, most long pronounced i sounds are writte as ie, but there is a much longer list of counter examples to that, so this is a rule of thumb at most.
Finally, there is no difference in pronunciation between i and ie, if the i sound is pronounced in its long version.
The problem is not so much the length (as a non-native speaker you can in case of doubt always resort to some intermediate length), but whether a special separation of e applies, as discussed in this German question.
Rule of thumb: ie is mostly long. There is a noticable shortening of long ies as in spazieren to participle spaziert, which results from loss of stress. For a definitive answer where the stress is, I see no alternative to a pronounciation dictionary.