You usually know it from the context. For your boyfriend you will also often see "mein Freund", whereas a friend is rather "ein Freund". Still "mein Freund" can also be just a friend.
- Das ist Peter, ein Freund von mir.
- Das ist mein Freund Peter.
The first case is clear: Peter is just a friend. If you are introduced to Peter as seen in the second example, then it's most likely her boyfriend.