Identifying sequences of actions required to complete tasks, based on data of completed tasks I have a list of about 20 tasks that a machine need to be performed by a machine. Each tasks consists of a sequence of 3 to 5 actions that must be executed sequentially to complete a task. There are a total of 50 different actions.

I want an algorithm to learn which actions to execute to complete the tasks. To learn this I have a dataset of approximately 1000 samples. Each sample consists of a task with corresponding actions. 

Given a task $T_n$, the machine needs to come up with the sequence of actions to complete the task.

Sample dataset ($T$ for tasks out of 20, $A$ for actions out of 50):
$T_1$ - $(A_5 \rightarrow A_1 \rightarrow A_3)$
$T_2$ - $(A_7\rightarrow A_12\rightarrow A_4\rightarrow A_1)$
$T_1$ - $(A_5\rightarrow A_3\rightarrow A_{13})$  

What is the best way to solve this?

Based on my knowledge of linear regression and classification, I believe that both are not the right approach to solve the task at hand.

EDIT 1:

One way I can think to solve this problem.
The machine doesn't have to come up with the whole sequence instantly.

If a new task has to be done, the machine has an option to choose the next action (first action) from, say, 5 available actions it can perform. After performing this action, it would have, say, 5 more actions and it has to choose it's next action to complete. And go on doing these actions to complete the given task.

Is this kind of a finite state machine?
What is the best way to solve this?
Based on my knowledge of linear regression and classification, I believe that both are not the right approach to solve the task at hand.

Not sure about the best way, but one indeed can formulate this kind of problem as a classification problem. I assume that additionally to the data included in your sample dataset you also have information about the environment for all 1,000 observations.
For example, one can reshape the dataset as follows.
Underlying data (I've inserted env as a placeholder for the information about environment, you might have several variables describing the environment):
|task |env |action1 |action2 |action3 |action4 |action5 |
|:----|:---|:-------|:-------|:-------|:-------|:-------|
|T1   |E1  |A5      |A1      |A3      |END     |NA      |
|T2   |E2  |A7      |A12     |A4      |A1      |END     |
|T1   |E3  |A5      |A3      |A13     |END     |NA      |

Transformed dataset that can be passed to the classifier
|task |env | num_action|prev_action |action |
|:----|:---|----------:|:-----------|:------|
|T1   |E1  |          1|START       |A5     |
|T2   |E2  |          1|START       |A7     |
|T1   |E3  |          1|START       |A5     |
|T1   |E1  |          2|A5          |A1     |
|T2   |E2  |          2|A7          |A12    |
|T1   |E3  |          2|A5          |A3     |
|T1   |E1  |          3|A1          |A3     |
|T2   |E2  |          3|A12         |A4     |
|T1   |E3  |          3|A3          |A13    |
|T1   |E1  |          4|A3          |END    |
|T2   |E2  |          4|A4          |A1     |
|T1   |E3  |          4|A13         |END    |
|T2   |E2  |          5|A1          |END    |

Then one can apply any multiclass classification (e.g. multinomial logistic regression) and try to predict the column action using the first four columns as predictors.